...
This application note explains how to use the STM32H7 RTC in the FreeRTOS demo application.
1. Understanding RTC Interfaces
1.1. FreeRTOS RTC Implementation
The FreeRTOS BSP makes use of the STM32CubeH7 software component to provide a device driver for the STM32H7 RTC. The driver is configured (enabled / disabled) at the BSP build time, using the HAL_RTC_MODULE_ENABLED
configuration option, defined in the stm32h7xx_hal_conf.h
file.
1.2. FreeRTOS RTC C-Binding API
The RTC driver implements the following C-binding API:
Function | Description | Comments |
| ||
Initialize the RTC according to the specified parameters in hrtc |
| |
| ||
De-initialize the RTC peripheral |
| |
| ||
Get RTC current date |
| |
| ||
Get RTC current time |
| |
| ||
Set RTC current date |
| |
| ||
Get RTC current time |
|
The RTC_HandleTypeDef
data structure used in the HAL_RTC_Init
interface has the following definition:
Code Block |
---|
typedef struct { RTC_TypeDef * Instance; /* Register base address */ RTC_InitTypeDef Init; /* RTC required parameters */ HAL_LockTypeDef Lock; /* RTC locking object */ __IO HAL_RTCStateTypeDef State; /* Time communication state */ } RTC_HandleTypeDef; |
The RTC_InitTypeDef
data structure used in RTC_HandleTypeDef
has the following definition:
Code Block |
---|
typedef struct { uint32_t HourFormat; /* Specifies the RTC Hour Format. */ uint32_t AsynchPrediv; /* Specifies the RTC Asynchronous Predivider value. */ uint32_t SynchPrediv; /* Specifies the RTC Synchronous Predivider value. */ uint32_t OutPut; /* Specifies which signal will be routed to the RTC output. */ uint32_t OutPutRemap; /* Specifies the remap for RTC output. */ uint32_t OutPutPolarity; /* Specifies the polarity of the output signal. */ uint32_t OutPutType; /* Specifies the RTC Output Pin mode. */ } RTC_InitTypeDef; |
2. RTC CLI Command
The FreeRTOS application implements the following RTC related CLI command:
Command | Description | Comments |
| Get the RTC time and date | |
| Set the RTC time and date |
|
3. Validating RTC Operation
Use the following step-wise procedure to validate the FreeRTOS RTC operation:
...