STM32L5 API and reference clock detection application example
STM32CubeL5 firmware libraries are the same as in STM32CubeL5 firmware libraries for smooth calibration application.
STM32CubeL5 firmware libraries are the same as in STM32CubeL5 firmware libraries for smooth calibration application.
X-CUBE-RTC shows an implementation of the reference clock detection (STM32CubeExpansion_AN4759_RTC_STM32L_Vx.y.z\Projects\NUCLEO-L552ZE-Q\RTC_RefClockDetection).
In order to use the application example project, the user needs a STM32L552ZE-Q Nucleo board (NUCLEO‑L552ZE-Q). Supply the board using the USB cable.
As indicated by the application name, a reference clock must be delivered to the STM32 for this application. For this goal, the user has to take a 50/60 Hz signal more precise than the LSE clock of the Nucleo board, and to inject it on the PB15 pin (position 26 on CN12 of the Nucleo board).
The user can check that the RTC prescalers are well configured for the board by verifying a 1 Hz signal is output on PB2 (RTC_OUT CALIB output).
Open the project under the user favorite IDE. For IAR Embedded Workbench, open the RTC_Synchronization.eww file. For MDK-ARM, open the RTC_Synchronization.uvprojx file. For STM32CubeIDE, open the .cproject file.
Compile and launch the debug session. It loads the program in the internal Flash memory and executes it.
The reference clock detection and synchronization are continuous. If the reference is lost, the RTC is still clocked by LSE.
time_elapsed variable deriving (getting away from 255/1 s). The user can monitor it in Debug mode.time_elapsed variable derivation is less important. time_elapsed embodies the 1-second period measured for RTC.
A typical quartz has an uncertainty of 53 s/month. This uncertainty must be attenuated with the reference clock detection and synchronization.
Moreover, to check that the application runs properly, the user can also visualize the user LED2 blinking each second and the RTC_OUT CALIB output on PB2 pin (these two observations do not witness the efficiency of the reference synchronization).
X-CUBE-RTC shows an implementation of the internal tamper detection in the folder:
STM32CubeExpansion_AN4759_RTC_STM32L_Vx.y.z\Projects\NUCLEO-L552ZE‑Q \RTC_InternalTamperCalOvf
This example uses the RTC firmware driver API mentioned in STM32L5 API and smooth digital calibration application example and STM32L5 API and synchronization application example. It is developed for the NUCLEO-L552ZE-Q board and exploits the ITAMP5 signal associated to a RTC calendar overflow event.
The user must supply the Nucleo board via USB, then compile and run the firmware with the preferred IDE. For IAR Embedded Workbench, open the RTC_Synchronization.eww file. For MDK-ARM, open the RTC_Synchronization.uvprojx file. For STM32CubeIDE, open the .cproject file.
The X-CUBE-RTC simply configures the RTC calendar at 23:59:30 on the 31st of December of the year xx99 and activates the internal tamper 5. The user can choose the polling mode or interrupt mode with the ITAMP_INTERRUPT constant in main.h: 1 is interrupt mode, 0 is polling mode.
When the seconds pass 59, the internal tamper event occurs and the green user led 1 PC7 if in polling mode, or the blue user LED2 PB7 if in interrupt mode, is turned on.
RTC_DR and RTC_TR allow the contents of the RTC calendar to be observed in debug mode.
The user can easily modify this example to exploit all the others internal tamper event sources.
| Date | Version | Changes |
|---|---|---|
| 26-May-2016 | 1 | Initial release. |
| 25-Oct-2016 | 2 | Updated:
|
| 11-May-2017 | 3 | Updated:
|
| 11-Feb-2019 | 4 | Updated:
|
| 12-Feb-2020 | 5 | Updated:
|
| 12-Feb-2020 (cont'd) | 5 | Added:
|
| 4-Jun-2021 | 6 | Updated with the STM32U5 Series:
Added:
|
| 20-Sep-2021 | 7 | Updated: |
| 08-Nov-2022 | 8 | Updated:
|
| 12-Mar-2024 | 9 | Updated: |
| 30-Jan-2025 | 10 | Updated: |
| 17-Feb-2026 | 11 |
Updated: |