AnsweredAssumed Answered

[STM32F4 Discovery] Can't breakpoint in RTC ISR

Question asked by shah.jitesh on Aug 5, 2015
Hi all,
I am evaluating STM32F4 Discovery board. I have quite a strange problem that I don't really understand. I generated a project via the STMCube software (no changes to the default discovery board config). I made the following changes to the project code later on: turn on LSI, turn on RTC and configure it to interrupt on every wake up event (Code I used at the end).

With these changes, I did get the RTC working well. The ISR is fired as programmed. However, I can break into the ISR only once. The second time around (even after a hard reset), I can never put a breakpoint and hit it successfully. I tried Keil's Uvision, System Workbench from ST and IAR workbench and quite strangely, saw the same symptoms on each of these IDEs. This makes me believe that problem is not tools related. If I inspect the registers in this state, I see that the WUTF flag is set in the RTC ISR register (suggesting that RTC wake up timer has fired). The EXTI pending register does not mark the interrupt as pending though (I can see the interrupt has been enabled in EXTI IMR register and NVIC ISER/ICER registers. Weird!)

I confirmed that the RTC was indeed firing by measuring the power consumption. The stop mode gives me ~0.6mA of current consumption. Configuring the ISR to fire every 1ms and executing code worth 200us, gives me a power consumption of ~4.5mA. This power consumption changes as I adjust my loops to take more/less time. There is no other peripheral which is on (all peripheral clocks are turned off), so I am pretty confident that the RTC ISR is firing. Just that I can't break into it using any of the IDEs. I thought it would be a tools issue, before seeing that happen on all the tools. Now I think its board related and hence, posting here.

Any help/tips appreciated. 


Code to enable RTC:
(LSI has already been turned on)
/* Enable debug in stop/sleep mode first */
/* Configure the system clock. This function also turns on the LSI */
/* Enable RTC wakeup interrupt and configure it to take the chip out of STOP mode */
/* Enable access to RTC registers and program them */
RTChandle.Instance = RTC;
while((RTChandle.Instance->ISR & (RTC_ISR_WUTWF)) == 0);
RTChandle.Instance->WUTR = 32 & RTC_WUTR_WUT;
RTChandle.Instance->CR |= (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1);

The RTC ISR is as follows:
void RTC_WKUP_IRQHandler(void)
    RTC_HandleTypeDef RTCHandle;
    RTCHandle.Instance = RTC;
    static unsigned int cnt = 0;