HAL TimeBase RTC Alarm Overview

Introducing HAL TimeBase RTC Alarm

group TimeBase_RTC_Alarm_Introduction

  • The RTC alarm timebase pattern provides an alternative to the default Cortex System Timer (SysTick) for the HAL timebase in STM32 microcontrollers.

  • This is useful in applications where SysTick is reserved for an RTOS, or when an ultra-low-power timebase is required. In this case, the RTC peripheral and its alarm feature are used to generate periodic interrupts for the HAL tick.

  • The RTC alarm timebase implementation is ready-to-use, requires no customization, and integrates seamlessly with the STM32 HAL.

Module and files

The following diagram illustrates the HAL TimeBase RTC Alarm module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the HAL TimeBase RTC Alarme module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.

@startuml
<style>
componentDiagram {
   arrow {
      FontSize 8
   }
}
</style>

title Timebase RTC Alarm Software Component Diagram

package "HAL" {
    [HAL_CORTEX]
    [HAL_RCC]
    [HAL_TIMEBASE_RTC_ALARM]
    [HAL_RTC]
}

package "Low Layer" {
    [LL_RTC]
    [CMSIS]
    [RTC Interrupt routine service]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_TIMEBASE_RTC_ALARM] : HAL Timebase RTC Alarm API
[Appli] <-- [HAL_TIMEBASE_RTC_ALARM] : RTC Alarm callback

[HAL_TIMEBASE_RTC_ALARM] --> [HAL_RTC] : HAL RTC API

[HAL_RTC] --> [LL_RTC] : LL RTC API
[HAL_RTC] -l-> [CMSIS] : IS_RTC_<FEATURE>_INSTANCE

[HAL_TIMEBASE_RTC_ALARM] -l-> [HAL_CORTEX] : HAL_CORTEX_NVIC_SetPriority
[HAL_RTC] -l-> [HAL_RCC] : HAL_RCC_RTCAPB_EnableClock

[HAL_RTC] <-- [RTC Interrupt routine service]

[LL_RTC] --> [CMSIS] : RTC register def

[STM32_HW] -u--> [RTC Interrupt routine service] : RTC Alarm IRQ
[STM32_HW] <-- [LL_RTC] : RTC registers R/W

@enduml

Configuration table

The following table lists the configuration defines for the HAL TimeBase RTC Alarm, specifying their locations, default values, and descriptions:

group TimeBase_RTC_Alarm_Configuration_Table

Configuration inside the timebase RTC alarm:

Config defines

Where

Default value

Note

USE_HAL_RTC_MODULE

hal_conf.h

1

Enable the HAL RTC module.

USE_ASSERT_DBG_PARAM

PreProcessor env

NA

Enable parameter assert.