ST STM32L0x3 Reference Manual page 1011

Ultra-low-power advanced arm-based 32-bit mcus
Table of Contents

Advertisement

RM0367
A.15.4
RTC read calendar code example
if((RTC->ISR
{
TimeToCompute
DateToCompute
}
A.15.5
RTC calibration code example
/* (1) Write access for RTC registers */
/* (2) Enable init phase */
/* (3) Wait until it is allow to modify RTC register values */
/* (4) set prescaler, 40kHz/125 => 320 Hz, 320Hz/320 => 1Hz */
/* (5) New time in TR */
/* (6) Disable init phase */
/* (7) Wait until it's allow to modify calibartion register */
/* (8) Set calibration to around +20ppm, which is a standard value @25°C */
/* Note: the calibration is relevant when LSE is selected for RTC clock */
/* (9) Disable write access for RTC registers */
RTC->WPR
RTC->WPR
RTC->ISR
while((RTC->ISR
{
/* add time out here for a robust application */
}
RTC->PRER
RTC->TR
RTC->ISR
while((RTC->ISR
{
/* add time out here for a robust application */
}
RTC->CALR
RTC->WPR
RTC->WPR
A.15.6
RTC tamper and time stamp configuration code example
/* Tamper configuration:
- Disable precharge (PU)
- RTCCLK/256 tamper sampling frequency
- Activate time stamp on tamper detection
- input rising edge trigger detection on RTC_TAMP2 (PA0)
- Tamper interrupt enable */
RTC->TAFCR
& RTC_ISR_RSF) == RTC_ISR_RSF)
= RTC->TR;
= RTC->DR;
= 0xCA;
/* (1) */
= 0x53;
/* (1) */
= RTC_ISR_INIT;
/* (2) */
& RTC_ISR_INITF)!=RTC_ISR_INITF)
= (124<<16) | 319;
=
RTC_TR_PM
| Time;
&=~ RTC_ISR_INIT;
& RTC_ISR_RECALPF) == RTC_ISR_RECALPF)
=
RTC_CALR_CALP
= 0xFE;
/* (9) */
= 0x64;
/* (9) */
=
RTC_TAFCR_TAMPPUDIS
/* get time */
/* need to read date also */
/* (4) */
/* (5) */
/* (6) */
| 482;
/* (8) */
|
RTC_TAFCR_TAMPFREQ
RM0367 Rev 7
Code examples
/* (3) */
/* (7) */
|
RTC_TAFCR_TAMPTS
1011/1043
1020

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32L0x3 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents