Skip to main content
Associate II
February 21, 2024
Solved

RTC choose several days

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 ! 

 

    This topic has been closed for replies.
    mƎALLEm
    mƎALLEmBest answer
    ST Technical Moderator
    February 21, 2024

    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.

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.

    4 replies

    Ghofrane GSOURI
    ST Technical Moderator
    February 21, 2024

    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

    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.
    FannyrsyAuthor
    Associate II
    February 21, 2024

    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.

    mƎALLEm
    mƎALLEmBest answer
    ST Technical Moderator
    February 21, 2024

    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.

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.