cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F4 RTC wake up from standby with ALARM_A and ALARM_B

David Lichterov
Associate II
Posted on July 26, 2017 at 17:00

Hello all, 

I am trying to set 2 ALARMS that will wake up my MCU. I want to set ALARM A to wake up the MCU at time X and set ALARM B to wake up the MCU at time X+Y. When i set both of the ALARMS only the first ALARM works. I am able to get 2 alarms working if i set the first one and then after the MCU wakes up from standby i set the second one (in this case it works only if i set both of the ALARMS as ALARM A/ALARM B - doesnt work if i set it with ALARM A and after the wakeup as ALARM B). 

My question is is it possible to set ALARM A for time X and then set ALARM B for time X+Y and then wake up the MCU 2 times from standby mode, one time with the first ALARM and another time with the second ALARM ??

1 ACCEPTED SOLUTION
8 REPLIES 8
Posted on July 26, 2017 at 22:01

Hello David!

What is your Hardware?

Provide us more details ..to try to help you.

David Lichterov
Associate II
Posted on July 27, 2017 at 08:22

Hey , I am using STM32F446RE, what other details you would like ?. my question is it possible to do what i am trying to do ? and if so is there a good example for that ? 

Thanks !!

Posted on July 27, 2017 at 15:23

Thanks for you answer it really helps me , but i am not sure how to preform the required steps.

The needed steps are : 

• 

Disable all used wakeup sources

• Clear all related wakeup flags

• Re-enable all used wakeup sources

• Enter Standby mode

I have couple of questions about the steps above : 

  • I can disable all my wake-up sources(ALARM A and B), but how do i Re-enable them ? 
  • What wakeup flags i should clear ?

Thank again !!

Posted on July 27, 2017 at 17:53

Hi again David!

wakeup flags are in the PWR power control/status register (PWR_CSR)   Are SBF and WUF.

____________________________________________________________

  /* Check and handle if the system was resumed from StandBy mode */

  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)

  {

  //do anything you need here (workaround Disable all used wakeup sources HAL_PWR_DisableWakeUpPin, HAL_RTC_DeactivateAlarm, __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(), etc.. )

  /* Clear Standby flag */

    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);

        /* Clear Wakeup flag */

     __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); // A wakeup event was received from the WKUP pin or from the RTC alarm       

  }

____________________________________________________________

//.......  your program runs  here

//before enter stby

set your allarms again here(initialise exti lines, allarm A , allarm B, wake up pins etc

//and finaly set standby mode

HAL_PWR_EnterSTANDBYMode(..);

while(1);// just to catch any inconsistence by debuging

// here your program finishes

Posted on July 27, 2017 at 18:02

One thing that I don't understand yet is the part of setting my alarms again . I need to set them from scratch ? Define again the times and all ? 

If my assumption above is correct , then I can't really use 2 alarms . If I want to set 2 alarms at the start of my program then tell the MCU to go to standby mode wake up from the first alarm and then go again to standby mode and wake up from the second alarm , then I will have to set the second alarm after I woke from the first standby ??? 

Do I understand this correctly? 

Posted on July 27, 2017 at 18:26

this errata workaround concerns wakup sources .

so ,setting allarms  mean set the interrupt sources of the allarms (__HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE().. check hal

https://my.st.com/content/ccc/resource/technical/document/user_manual/2f/71/ba/b8/75/54/47/cf/DM00105879.pdf/files/DM00105879.pdf/jcr:content/translations/en.DM00105879.pdf

(p. 725 ++ )for other posibilities)

A normal alarm with no wakeup connection is irrelevant to our case.

Also when disabling allarms means the interrupt source of this wakeup (__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE().. check hal

https://my.st.com/content/ccc/resource/technical/document/user_manual/2f/71/ba/b8/75/54/47/cf/DM00105879.pdf/files/DM00105879.pdf/jcr:content/translations/en.DM00105879.pdf

  

https://my.st.com/content/ccc/resource/technical/document/user_manual/2f/71/ba/b8/75/54/47/cf/DM00105879.pdf/files/DM00105879.pdf/jcr:content/translations/en.DM00105879.pdf

for other posibilities)

it was

redundancy

when  i wrote before to deactivate the RTC allarm itself (HAL_RTC_DeactivateAlarm).

Take a look also at

https://my.st.com/content/ccc/resource/technical/document/reference_manual/4d/ed/bc/89/b5/70/40/dc/DM00135183.pdf/files/DM00135183.pdf/jcr:content/translations/en.DM00135183.pdf

paragraph 5.3.7
Posted on July 30, 2017 at 15:18

Thank you very much !!! 

I got it working with your help .