Getting started with RTC

Revision as of 14:31, 18 November 2022 by Registered User (→‎Create the project in STM32CubeIDE)
Under construction.png Coming soon

This article explains how to use the RTC. It provides code examples to use RTC Alarm with interrupt.

1. RTC definition

A real-time clock (RTC) is an independent binary-coded decimal (BCD) timer/counter. For that, the RTC provides a time-of-day clock/calendar with programmable alarm interrupt. Also, the RTC can provide an automatic wakeup to manage all low-power modes. The STM32L476 integrated RTC peripheral can be used for different main features are the following:

  • Calendar with subseconds, seconds, minutes, hours, day, date of day in month, month and year.
  • Daylight saving compensation programmable by software.
  • Programmable alarm with interrupt function.
  • Automatic wakeup unit generating a periodic flag that triggers an automatic wakeup interrupt.
  • Reference clock detection: a more precise second source clock (50 or 60 Hz) can be used to enhance the calendar precision.
  • Accurate synchronization with an external clock using the subsecond shift feature.
  • Digital calibration circuit (periodic counter correction).
  • Time-stamp function for event saving.
  • Tamper detection event with configurable filter and internal pull-up.
  • 32 backup registers.
  • Maskable interrupts/events:

- Alarm A
- Alarm B
- Wakeup interrupt
- Time-stamp
- Tamper detection

2. Configure RTC and Alarm with interrupt

2.1. Objectives

The objectives of this wiki article are to know how to setup RTC with interrupt in STM32CubeIDE and how to create a simple RTC project with periodic alarm interrupt.

2.2. How

Configure the LED pin and the RTC alarm interrupts in STM32CubeIDE and generate code.
Verify the correct functionality by periodic RTC alarm interrupts and by toggle the LED.

2.3. Create the project in STM32CubeIDE

  • File>New>STM32 Project in main panel.

create STM32CubeIDE project.png



[[category:Getting_started_with_STM32_system_peripherals | 15]]