AnsweredAssumed Answered

STM32F405 Locked in Standby mode when using more than one wakeup source

Question asked by rodrigues.walter on Dec 29, 2015
Latest reply on Dec 29, 2015 by rodrigues.walter

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/static/active/en/resource/technical/document/errata_sheet/DM00037591.pdf</a></span></p>

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)

void Power_Save_Go_to_StandBy()
{

     //Disable all used wakeup sources
    PWR_WakeUpPinCmd(DISABLE);
    RTC_WakeUpCmd(DISABLE);  
   
    //Clear all related wakeup flags
    EXTI->PR = 0x007FFFFF;
    PWR_ClearFlag(PWR_FLAG_SB);
    RTC_WaitForSynchro();
    PWR_ClearFlag(PWR_FLAG_WU);
    PWR->CR |= PWR_CR_CWUF;
    RTC_ClearITPendingBit(RTC_IT_WUT);
    EXTI_ClearITPendingBit(EXTI_Line22);
    RTC_ClearFlag(RTC_FLAG_WUTF);

    RTC_SetWakeUpCounter(60);         // Specifies the RTC WakeUp counter in seconds.
    RTC_ITConfig(RTC_IT_WUT, ENABLE);

    //Re-enable all used wakeup sources
    PWR_WakeUpPinCmd(ENABLE);
    RTC_WakeUpCmd(ENABLE);
    
    //Enter Standby mode
    PWR_EnterSTANDBYMode();

}


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).  

Thanks,

Walter

Outcomes