cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32L4] [Discovery Kit] RTC Re-Calibration on-the-fly and Smooth digital Calibration configuration

sunny
Associate II
Posted on May 18, 2016 at 14:38

Hi,

I am using the STM32L4 Discovery Kit and I wanted to enable the RTC Re-Calibration / Smooth digital Calibration configuration. The board RTC is using the on board LSE  Oscillator having 32.768 kHz clock

I found out from the Reference Manual about this and also there is a API HAL_RTCEx_SetSmoothCalib() by which we can enable the RTC Calibration.

But I am a bit confused about its usage.

I have calling the API with the below parameters:

HAL_RTCEx_SetSmoothCalib(&RtcHandle, 

                                        RTC_SMOOTHCALIB_PERIOD_8SEC, 

    RTC_SMOOTHCALIB_PLUSPULSES_SET, 

                                1);

but I am not sure how does the CALM and CALP work. I saw the formula in the Reference Manual, but still I am not clear about what does the Masking of the Clock Pulses mean when configuring the CALM as a non-zero value.

Thanks,

Sunny

#calibration #rtc #stm32l4
3 REPLIES 3
Posted on May 18, 2016 at 22:35

Inserting a single cycle over the observation time would be of the form

HAL_RTCEx_SetSmoothCalib(&RtcHandle, 

RTC_SMOOTHCALIB_PERIOD_8SEC, 

RTC_SMOOTHCALIB_PLUSPULSES_SET, 

512 - 1);

Removing one

HAL_RTCEx_SetSmoothCalib(&RtcHandle, 

RTC_SMOOTHCALIB_PERIOD_8SEC, 

RTC_SMOOTHCALIB_PLUSPULSES_RESET, 

1);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 07, 2018 at 09:35

Hi

I have also trouble setting up the CALM register.

The note on the STM32L4 RM0351about CALM setup is not clear at all.

CALM[8:0] (RTC_CALR) specifies the number of RTCCLK pulses to be masked during the

32-second cycle. Setting the bit CALM[0] to ‘1’ causes exactly one pulse to be masked

during the 32-second cycle at the moment when cal_cnt[19:0] is 0x80000; CALM[1]=1

causes two other cycles to be masked (when cal_cnt is 0x40000 and 0xC0000); CALM[2]=1

causes four other cycles to be masked (cal_cnt = 0x20000/0x60000/0xA0000/ 0xE0000);

and so on up to CALM[8]=1 which causes 256 clocks to be masked (cal_cnt = 0xXX800).

can anyone explain what it means.

The CALM value is subtracted from the 2^20 counter or not ?

Posted on March 07, 2018 at 10:51

I wouldn't use the word 'subtracted'; I'd say, CALM pulses in 2^20 pulses are skipped.

It means, that until the 2^20 counter overflows, (2^20 + CALM) crystal oscillations elapse.

JW