I have been battling with a problem which blocks wakeup from Standby mode when using more than one wakeup source (RTC and Wakeup Pin PA0) this has already been identified and acknowledged by ST and the solution to the problem is provided in "STM32F40x and STM32F41x Errata sheet Section 2.1.5 http://www.st.com/st-web-ui/ According to ST the Workaround to avoid this problem is to apply the following sequence before entering Standby mode:
• Disable all used wakeup sources,
• Clear all related wakeup flags,
• Re-enable all used wakeup sources,
• Enter Standby mode
I am trying to use RTC Wakeup Timer and the Wakeup pin PA0 simultaneously. However I have found that the microcontroller works as expected only if one is enabled at a time and not both (RTC and Wakeup pin PA0).
Here is the code. Assuming that I have enabled the RTC correctly (since RTC wakeup works as expected on its own)
//Disable all used wakeup sources
//Clear all related wakeup flags
EXTI->PR = 0x007FFFFF;
PWR->CR |= PWR_CR_CWUF;
RTC_SetWakeUpCounter(60); // Specifies the RTC WakeUp counter in seconds.
//Re-enable all used wakeup sources
//Enter Standby mode
When I execute this code. I have the following results.
Scenario 1: The Wakeup Pin PA0 gets the controller out of standby provided its within 60 seconds. After 60 seconds (When the RTC counter expires) the RTC doesn't wakeup the controller. Nor does the Wakeup pin PA0. And one has to power restart the microcontroller.
Scenario 2: If the PWR_WakeUpPinCmd is Disabled then every 60 seconds the RTC wakes up the controller.
Scenario 3: If RTC_WakeUpCmd is Disabled then the Wakeup Pin PA0 gets the controller out of standby whenever it receives a wakeup signal.
I want to be able to use both the RTC Wakeup and the Wakeup Pin PA0. If a wakeup signal on PA0 is asserted the controller should come out of standby. If not the controller should come out of standby periodically using RTC whenever the RTC counter expires (here its every 60 sec).
According to ST the Workaround to avoid this problem is to apply the following sequence before entering Standby mode: