AN4759

STM32L5 API and smooth digital calibration application example

6STM32L5 API and smooth digital calibration application example

6.1STM32CubeL5 firmware libraries for smooth calibration application

The timer peripheral (TIM) comes with:

a firmware driver API abstracting TIM features for the end-user

Refer to stm32l5xx_hal_tim.c and stm32l5xx_hal_tim_ex.c files in \STM32Cube_FW_L5_Vx.y.z\Drivers\STM32L5xx_HAL_Driver\

a set of example projects in \STM32Cube_FW_L5_Vx.y.z\Projects\ NUCLEO-L552ZE-Q\Examples\TIM

The RTC comes with:

a firmware driver API abstracting TIM features for the end-user

Refer to stm32l5xx_hal_rtc.c and stm32l5xx_hal_rtc_ex.c files in \STM32Cube_FW_L5_Vx.y.z\Drivers\STM32L5xx_HAL_Driver\

a set of example projects in \STM32Cube_FW_L5_Vx.y.z\Projects\ NUCLEO-L552ZE-Q\Examples\RTC

6.2X-CUBE-RTC for smooth calibration

X-CUBE-RTC shows an implementation of the smooth digital calibration feature of the RTC (using also the GPTIMER HAL API).

In this example, the RTC_CLK is smoothly calibrated based on an external 1 Hz reference (STM32CubeExpansion_AN4759_RTC_STM32L_Vx.y.z\Projects\NUCLEO-L552ZE-Q\RTC_SmoothCalib).

The firmware implements:

a GPTIMER (general-purpose timer) in Master mode using channel 1 in output compare mode (and using an external trigger clock)

a GPTIMER in Master mode using channel 1 in input capture mode and channel 2 in output compare mode This timer is also configured to use the LSE clock thanks to the TIM option register.

the RTC with the CALR register programming

GPIOs to connect the input 1 Hz reference clock and the “corrected” RTC_OUT_CALIB clock

AN4759 - Rev 8

page 45/60