cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0xx RTC wake up

meir2
Associate
Posted on May 05, 2014 at 17:04

Hi,

I'm trying to config wake up from deep sleep (STOP mode) in STM32F030 for 1350 milli seconds.

I've found a way to wake up in resolution of seconds with the Alarm with the following code:

   RTC_TimeTypeDef   RTC_TimeStructure;

    RTC_AlarmTypeDef  RTC_AlarmStructure;

    secondsLoad = wakeUpCounter / ONE_SECOND;    

  

    // Get current time 

    RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);

    // Set the alarm to current time + Xs 

    RTC_AlarmStructure.RTC_AlarmTime.RTC_H12     = RTC_H12_AM;

    RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours   = RTC_TimeStructure.RTC_Hours;

    RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = RTC_TimeStructure.RTC_Minutes;

    RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = RTC_TimeStructure.RTC_Seconds + secondsLoad;

    RTC_AlarmStructure.RTC_AlarmDateWeekDay = 31;

    RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;

    RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Minutes |

                                     RTC_AlarmMask_Hours;

    RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);

As well I can configure wake up with resolution of sub seconds as following:

    if (wakeUpCounter > secondsLoad * ONE_SECOND)

    {  

        // Set AlarmA subseconds and enable SubSec Alarm : generate x interripts per Second 

        RTC_AlarmSubSecondConfig(RTC_Alarm_A, (wakeUpCounter - secondsLoad * ONE_SECOND), 7);

    }  

But I don't know how to configure it for 1.350 sec. (or 15.56sec)

Thanks you very much in advance for answer!

Meir

#wakeup #real-time-clock-rtc-alarm #timer #rtc #stm32
0 REPLIES 0