Skip to content

Commit

Permalink
Fix timing in SEGGER SysView (#1279)
Browse files Browse the repository at this point in the history
### Changelist 
<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->

SEGGER SystemView needs to be configured after the clocks have been
configured or the timing is wrong. Fixed!

### Testing Done
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->

Tested on VC.
  • Loading branch information
gtaharaedmonds authored May 24, 2024
1 parent 8f44cf0 commit a20e8db
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
9 changes: 5 additions & 4 deletions firmware/quadruna/BMS/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,15 @@ void tasks_preInit(void)
{
// After booting, re-enable interrupts and ensure the core is using the application's vector table.
hw_bootup_enableInterruptsForApp();

// Configure and initialize SEGGER SystemView.
SEGGER_SYSVIEW_Conf();
LOG_INFO("BMS reset!");
}

void tasks_init(void)
{
// Configure and initialize SEGGER SystemView.
// NOTE: Needs to be done after clock config!
SEGGER_SYSVIEW_Conf();
LOG_INFO("VC reset!");

__HAL_DBGMCU_FREEZE_IWDG1();

HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED);
Expand Down
9 changes: 5 additions & 4 deletions firmware/quadruna/CRIT/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,15 @@ static const BoardShdnNode crit_bshdn_nodes[CritShdnNodeCount] = {
void tasks_preInit(void)
{
hw_bootup_enableInterruptsForApp();

// Configure and initialize SEGGER SystemView.
SEGGER_SYSVIEW_Conf();
LOG_INFO("CRIT reset!");
}

void tasks_init(void)
{
// Configure and initialize SEGGER SystemView.
// NOTE: Needs to be done after clock config!
SEGGER_SYSVIEW_Conf();
LOG_INFO("VC reset!");

// Start DMA/TIM3 for the ADC.
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)hw_adc_getRawValuesBuffer(), hadc1.Init.NbrOfConversion);
HAL_TIM_Base_Start(&htim3);
Expand Down
9 changes: 5 additions & 4 deletions firmware/quadruna/FSM/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ static bool (*const heartbeatFaultGetters[HEARTBEAT_BOARD_COUNT])(void) = {
void tasks_preInit(void)
{
hw_bootup_enableInterruptsForApp();

// Configure and initialize SEGGER SystemView.
SEGGER_SYSVIEW_Conf();
LOG_INFO("FSM reset!");
}

static const FsmShdnConfig fsm_shdn_pin_config = { .fsm_shdn_ok_gpio = fsm_shdn };
Expand All @@ -191,6 +187,11 @@ static const BoardShdnNode fsm_bshdn_nodes[FsmShdnNodeCount] = { { &io_fsmShdn_F

void tasks_init(void)
{
// Configure and initialize SEGGER SystemView.
// NOTE: Needs to be done after clock config!
SEGGER_SYSVIEW_Conf();
LOG_INFO("VC reset!");

__HAL_DBGMCU_FREEZE_IWDG();

HAL_ADC_Start_DMA(&hadc1, (uint32_t *)hw_adc_getRawValuesBuffer(), hadc1.Init.NbrOfConversion);
Expand Down
9 changes: 5 additions & 4 deletions firmware/quadruna/RSM/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,15 @@ static bool (*const heartbeatFaultGetters[HEARTBEAT_BOARD_COUNT])(void) = {
void tasks_preInit(void)
{
hw_bootup_enableInterruptsForApp();

// Configure and initialize SEGGER SystemView.
SEGGER_SYSVIEW_Conf();
LOG_INFO("RSM reset!");
}

void tasks_init(void)
{
// Configure and initialize SEGGER SystemView.
// NOTE: Needs to be done after clock config!
SEGGER_SYSVIEW_Conf();
LOG_INFO("VC reset!");

__HAL_DBGMCU_FREEZE_IWDG();

// Start DMA/TIM3 for the ADC.
Expand Down
8 changes: 4 additions & 4 deletions firmware/quadruna/VC/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ bool (*const heartbeatFaultGetters[HEARTBEAT_BOARD_COUNT])(void) = {
void tasks_preInit(void)
{
hw_bootup_enableInterruptsForApp();
}

void tasks_init(void)
{
// Configure and initialize SEGGER SystemView.
SystemCoreClockUpdate();
// NOTE: Needs to be done after clock config!
SEGGER_SYSVIEW_Conf();
LOG_INFO("VC reset!");
}

void tasks_init(void)
{
__HAL_DBGMCU_FREEZE_IWDG1();

hw_hardFaultHandler_init();
Expand Down

0 comments on commit a20e8db

Please sign in to comment.