I'm having a significant problem debugging my board with CAN traffic. Whenever the debugger is paused, and a CAN message is received, the independent watchdog is being reset. As far as I can tell, I'm disabling that peripheral on debug correctly, but anytime I set a breakpoint, the IWDG is resetting the MCU. If my board does NOT receive any CAN messages, everything works as expected.
Relevant Information MCU: STM32F091VB Development Environment: IAR Embedded Workbench 9.30 Debug Probe: STLink/V2 Below is my code for disabling peripherals for debugging:
//Halt Interrupts on Debug stop
__HAL_RCC_DBGMCU_CLK_ENABLE();
__HAL_FREEZE_IWDG_DBGMCU();
__HAL_FREEZE_WWDG_DBGMCU();
__HAL_FREEZE_TIM1_DBGMCU();
__HAL_FREEZE_TIM2_DBGMCU();
__HAL_FREEZE_TIM3_DBGMCU();
__HAL_FREEZE_TIM16_DBGMCU();
__HAL_FREEZE_CAN_DBGMCU();
Disabling the watchdog entirely appeared to work, but pausing in the debugger only allows me to debug the CAN interrupt i.e. I'm stuck infinitely in that interrupt, even if there are no CAN messages being received.
Here are the CAN registers, just before the Receive Mailbox Interrupt is cleared:
In addition, here is the DBGMU Register
Found the answer. I was reorganizing my code, and choosing a different implementation for initializing CAN hardware. New implementation removed these three lines:
RCC->APB1RSTR &= ~RCC_APB1RSTR_CANRST;
RCC->APB1ENR |= RCC_APB1ENR_CANEN;
CAN->MCR = 0x00008000;
After that, I was able to debug as normal. Not exactly sure which line is the culprit, but suffice to say HAL libraries for the win.