RTC_Alarm_Init Example Description

Configuration of the RTC LL API to configure and generate an alarm using the RTC peripheral. The peripheral initialization uses the LL initialization function.

In this example, after start-up, SYSCLK is configured to the max frequency using HSI as clock source.

The RTC peripheral configuration is ensured by the Configure_RTC() function (configure of the needed RTC resources according to the used hardware CLOCK, PWR, RTC clock source and BackUp). You may update this function to change RTC configuration.

Notes

  1. LSI oscillator clock is used as RTC clock source by default. The user can use also LSE as RTC clock source.

    • The user uncomment the adequate line on the main.c file.

      @code

      #define RTC_CLOCK_SOURCE_LSI

      /* #define RTC_CLOCK_SOURCE_LSE */

      @endcode

    • Open the ioc file with STM32CubeMX and select :

      LSE as “Crystal/Ceramic Resonator” in RCC configuration.

      LSE as RTC clock source in Clock configuration.

    • Generate code

    LSI oscillator clock is delivered by a 32 kHz RC.

    LSE (when available on board) is delivered by a 32.768 kHz crystal.

Configure_RTC_Alarm function is then called to initialize the time, date and alarm.

In this example, the Time is set to 11:59:55 PM and the Alarm must be generated after 30 seconds on 12:00:25 AM.

LED3 is turned ON when the RTC Alarm is generated correctly.

The current time and date are updated and displayed on the debugger in aShowTime and aShowDate variables (watch or live watch).

In case of error, LED3 is toggling.

Keywords

System, RTC, Alarm, wakeup timer, Backup domain, Counter, LSE, LSI

Directory contents

Hardware and Software environment

How to use it ?

In order to make the program work, you must do the following :