cancel
Showing results for 
Search instead for 
Did you mean: 

How to set RTC Alarm in stm32

Manjunatha S
Associate II
Posted on May 28, 2013 at 14:15

Hi! All,

I want to set RTC alarm for specific date and time can any one help me in this regard? i use STM32l151vbt6.

Thank You,

#stm32l1-rtc-alarm
3 REPLIES 3
Posted on May 28, 2013 at 16:11

Not sure it's that flexible, you can't just pluck any specific date off the calender.

You should be able to do a time, and day of week, Or time and day of month (current/next).

So you might be able to generate an Alarm for 09:09 AM Day 29, it will fire at that specific time/day every month (09:09:00 29-May, 09:09:00 29-June, .. ), and you'd need to determine if it was the right month and go back to sleep if not.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
infoinfo980
Associate II
Posted on May 28, 2013 at 18:19

Using the functions in <time.h> fill in a 'tm' structure with the current date and time. Use mktime to get a time_t from it. A time_t is a 1Hz counter with zero based way back in 1970. Set the RTC ticker from this value so your clock is sync'd with Unix time. Do the same for your desired alarm value and that should do it.

Remember to run your RTC off an accurate source such as an LSE. The STM32 LSI is far from accurate, as I've discovered.

Posted on May 28, 2013 at 19:18

The L1 is a calendered device, the F1 could have used a 32-bit hertz counter which you could apply any date zero basis you want. That could be set to Alarm quite distant and singular dates in the future.

The STM32 series will ONLY maintain the RTC ticking using an external LSE crystal, in STANDBY mode. The internal LSI is neither accurate, nor functional from the backup power domain.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..