2010-01-10 01:58 AM
Can't reliably read RTC_FLAG_ALR on wakeup
2011-05-17 04:34 AM
On wakeup from Standby caused by a RTC alarm, I can't read the RTC_FLAG_ALR flag reliably.
It always reads as 0 (no RTC alarm) even though the wakeup is obviously being caused by the RTC based on the wakeup period. The exception is that it does work when on the debugger (Keil Ulink2). Here is the main code. int main(void) { /* Enable clock for PWR and BKP registers */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); PWR_BackupAccessCmd(ENABLE); /* Since either reset or wake from standby need resync */ RTC_WaitForSynchro(); /* Check if we were woken by RTC Alarm, or processor was reset */ if ( RTC_GetFlagStatus(RTC_FLAG_ALR) == SET ) { // NOTE: Never gets here, even when definite wakeup RTC_ALARM /* Wakeup from standby */ } else { /* Assume power-on reset, do full init */ } } Any help would appreciated. Regards, Tyler2011-05-17 04:34 AM
Hi Tyler,
This is an expected behavior because when the the system is in Standby by mode, the peripherals clock are disabled. After waking up from Standby mode, program execution restarts in the same way as after a Reset and all registers are reset after wakeup from Standby except for Power control/status register (PWR_CSR). The RTC alarm event will wakeup the syestem from standby mode but RTC alarm flasg won't be set. Please refer to Refer to Figure 156. RTC simplified block diagram in RM0008 and to Note 3 in the RTC_CRL register in RM0008 : '' The OWF, ALRF, SECF and RSF bits are not updated when the APB1 clock is not running.'' Cheers, :D