cancel
Showing results for 
Search instead for 
Did you mean: 

Can't reliably read RTC_FLAG_ALR on wakeup

tcoen
Associate
Posted on January 10, 2010 at 10:58

Can't reliably read RTC_FLAG_ALR on wakeup

2 REPLIES 2
tcoen
Associate
Posted on May 17, 2011 at 13:34

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,

Tyler

kaouther
Associate II
Posted on May 17, 2011 at 13:34

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