2024-02-21 05:20 AM
Hi everyone!
I use RTC with STM32CubeIDE for my STM32. Just a question: is it possible to set the alarm day over several days so that the alarm wakes up every Monday AND Friday?
Thank you !
Solved! Go to Solution.
2024-02-21 06:58 AM - edited 2024-02-21 07:00 AM
You need to manage it by software with one Alarm. In the interrupt alarm callback you need to check the day (day comparison), if it does match you execute what you want, else you do nothing.
2024-02-21 05:33 AM - edited 2024-02-21 05:48 AM
Hello @Fannyrsy
First let me thank you for posting.
In the RTC (Real-Time Clock) module of STM32 microcontrollers, it is not possible to directly set an alarm to wake up on specific days of the week using a single alarm configuration. The RTC alarm feature typically allows you to set a specific date and time for the alarm to trigger, but it does not provide a built-in mechanism for recurring alarms on specific days.
To achieve the functionality you described—waking up every Monday and Friday—you would need to implement a more complex logic in your project.
1. Set up two separate alarms—one for Monday and another for Friday—using the RTC alarm feature. Configure the alarms to trigger at the desired time on those respective days.
2. In the interrupt handler for the RTC alarm, check which alarm has triggered (Monday or Friday). Perform the required actions or set a flag to indicate the alarm event.
3. In your main program loop or another relevant section, implement the logic to check the flag set in the interrupt handler. If the flag indicates that the alarm has triggered, execute the desired actions. You may also need to reset the flag for future alarms.
4. Additionally, ensure that the RTC module is configured correctly with the appropriate clock source and prescaler to maintain accurate timekeeping.
You can refer to this LINK in order to understand more about the RTC
THX
Ghofrane
2024-02-21 06:01 AM
Thank you for your response!! So it's impossible to wake up uC more than 2 days because the uC has only 2 alarms? I want the uC to execute the same action more than 2 days (like water a garden).
Thanks again.
2024-02-21 06:58 AM - edited 2024-02-21 07:00 AM
You need to manage it by software with one Alarm. In the interrupt alarm callback you need to check the day (day comparison), if it does match you execute what you want, else you do nothing.
2024-02-21 07:18 AM
Thanks a lot you helped me, I haven't think about that!