2017-07-26 08:00 AM
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 ??
Solved! Go to Solution.
2017-07-27 04:58 AM
Hello again!!
Look at this
(Errata sheet) page 112017-07-26 01:01 PM
Hello David!
What is your Hardware?
Provide us more details ..to try to help you.
2017-07-26 11:22 PM
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 !!
2017-07-27 04:58 AM
Hello again!!
Look at this
(Errata sheet) page 112017-07-27 08:23 AM
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 :
Thank again !!
2017-07-27 10:53 AM
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
2017-07-27 11:02 AM
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?
2017-07-27 11:26 AM
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
(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
for other posibilities)it was
redundancy
when i wrote before to deactivate the RTC allarm itself (HAL_RTC_DeactivateAlarm).Take a look also at
paragraph 5.3.72017-07-30 08:18 AM
Thank you very much !!!
I got it working with your help .