cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32F4 Discovery] Can't breakpoint in RTC ISR

jitesh
Associate
Posted on August 05, 2015 at 02:17

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. Thanks, Jitesh Code to enable RTC: (LSI has already been turned on)

/* Enable debug in stop/sleep mode first */
HAL_DBGMCU_EnableDBGSleepMode();
HAL_DBGMCU_EnableDBGStopMode();
/* Configure the system clock. This function also turns on the LSI */
SystemClock_Config();
/* Enable RTC wakeup interrupt and configure it to take the chip out of STOP mode */
NVIC_EnableIRQ(RTC_WKUP_IRQn);
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();
__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
/* Enable access to RTC registers and program them */
RTChandle.Instance = RTC;
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
__HAL_RCC_RTC_ENABLE();
__HAL_RTC_WRITEPROTECTION_DISABLE(&RTChandle);
__HAL_RTC_WAKEUPTIMER_DISABLE(&RTChandle);
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);
__HAL_RTC_WAKEUPTIMER_ENABLE(&RTChandle);
__HAL_RTC_WAKEUPTIMER_ENABLE_IT(&RTChandle, RTC_IT_WUT);

The RTC ISR is as follows:

void
RTC_WKUP_IRQHandler(
void
)
{
RTC_HandleTypeDef RTCHandle;
RTCHandle.Instance = RTC;
static
unsigned 
int
cnt = 0;
cnt++;
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&RTCHandle, RTC_FLAG_WUTF);
__HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
}

#debugger #rtc #breakpoint
0 REPLIES 0