Skip to main content
Associate
June 29, 2026
Solved

STM32WL55JC1 RTC Alarm at calendar date and time

  • June 29, 2026
  • 1 reply
  • 44 views

Hi, 
I’m looking into the WL55JC1 for a project which would require the system to remain dormant (ideally standby) for weeks, maybe months and then resume operation on a set date at a set time. I would like to use LSI as power and space will be very limited.

So far I’ve discovered, that of course there is an RTC and it has alarms that can be used to wake from standby mode. However all examples and documentation I can find only ever use times or maybe day-of-week or day-of-month as the set wake up time. Never a full date and time. Looking at the code, stm32wlxx_hal_rtc.h defines a struct RTC_AlarmTypeDef with fields for seconds, minutes, hours and either a day-of-month, or day-of-week.
Is it really not possible to give the system a full a date and time yyyy-mm-dd and hh-mm to wake up at? Will I need to build workaround waking up at least once a month to recalculate the next wake-up until the actual target time is within the same calendar month?
Or am I overlooking something?

I’d appreciate any help I can get, thank you!
 

Best answer by Peter BENSCH

If you need a correct RTC clock, the only alternatives are (in my view, in order of increasing implementation effort):

  1. LSE
  2. external RTC
  3. external reference clock

The STM32 RTC alarm is not a general full-date comparator. It only checks the fields that are enabled by the mask. So you can match on hour/minute/second and, depending on the mode, either day-of-month or day-of-week -  but not a complete arbitrary yyyy-mm-dd hh:mm:ss alarm in one hardware shot.

For a far-future exact wake-up, the usual approach is:

  • Keep the RTC running
  • Set an intermediate alarm
  • Wake up periodically
  • Compare the current date/time with the target in software
  • Re-arm the next alarm until the target is reached

In summary: the practical workaround is “wake occasionally, check whether the year/month/day is correct, then go back to sleep”.

Hope that answers your question?

Regards
/Peter

1 reply

Peter BENSCH
ST Technical Moderator
June 29, 2026

Welcome ​@plecso, to the community!

Even though space is limited - if your system is supposed to wake up after months on a specific date, LSI is very poorly suited as a clock source for the RTC. Why? In the datasheet, for fLSI and the full temperature range, you will find a frequency variation of 29.5...34kHz. If you start from the arithmetic mean value (31.75 kHz), a simple calculation gives a daily inaccuracy of 29.5/31.75-1 = -70866 ppm (the same absolute value in the positive direction), which corresponds to a possible daily deviation of up to 6922.8 seconds. Assuming 30.25 days per month and a total of e.g. 6 months, this can add up to more than 1 million seconds = 12.8 days. In such a case, you cannot even be sure of hitting the correct week.

Even if the RTC is operated with LSE, careful design is extremely important in order not to accumulate too much drift over such periods, since the crystal’s temperature profile, load capacitor parameters, and even the layout all have a non-negligible effect. I strongly recommend carrying out a worst-case analysis for such accuracy requirements, taking all relevant parameters into account.

Coming back to your question about the date: the RTC has at least one small limitation - the year can only be evaluated using the last two digits, because the millennium and century are not managed in the RTC hardware. So if you want to be woken at a specific time on a specific date, you can certainly do that; however, for the reasons of accuracy mentioned above, this is relatively rare and would need to be implemented, for example, with a custom typedef or something similar.

Hope that helps?

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
plecsoAuthor
Associate
July 9, 2026

Hi Peter,

thank you for your insights!
Indeed I did not consider that LSI might not be accurate enough, I’m going to have to look into alternatives.

As for the RTC alarm I still don’t understand how I would be able to get an alarm at a specific date. I followed the alarm setting path in the HAL down to the point where (as far as I can tell) it writes a uint32 with BCD encoded alarm time into a register within the RTC module. This alarm time is always hours, minutes, seconds, AM/PM, WeekDay/MonthDaySelector, Day (in week or month) and a mask selecting which of these are relevant.

Even if I were to change the composition of this uint32, how would the RTC alarm know how to interpret it? Is it programmable as well?

As you can likely tell, I'm somewhat in over my head, so I would really appreciate any help or pointers!

Regards,
Philipp

Peter BENSCH
Peter BENSCHBest answer
ST Technical Moderator
July 9, 2026

If you need a correct RTC clock, the only alternatives are (in my view, in order of increasing implementation effort):

  1. LSE
  2. external RTC
  3. external reference clock

The STM32 RTC alarm is not a general full-date comparator. It only checks the fields that are enabled by the mask. So you can match on hour/minute/second and, depending on the mode, either day-of-month or day-of-week -  but not a complete arbitrary yyyy-mm-dd hh:mm:ss alarm in one hardware shot.

For a far-future exact wake-up, the usual approach is:

  • Keep the RTC running
  • Set an intermediate alarm
  • Wake up periodically
  • Compare the current date/time with the target in software
  • Re-arm the next alarm until the target is reached

In summary: the practical workaround is “wake occasionally, check whether the year/month/day is correct, then go back to sleep”.

Hope that answers your question?

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.