RTC adjust?
Posted: Thu Jul 18, 2024 2:15 pm
Hi,
again I'm using a STM32G0B1CBT6-board.
At VBAT-pin two NiMH-rechargables are connected, so ≈ 2,6 V.
First I used the simpleRTC-example to see, how accuracy is with LSE crystal.
During the first 10 minutes RTC is 11 ms too slow - comparing to timestamp of PC.
I let it run over night for 12 hours and can estimates, that RTC will be 1,5 s too slow in 24 hours. That's 17,4 ppm and inside range from datasheet.
I like to adjust RTC.
Reference manual tells me something about CALP and CALM.
And I found HAL_RTCEx_SetSmoothCalib() inside stm32g0xx_hal_rtc_ex.c ...
But it looks like it has no effect.
RTC is never going faster.
Can I mix this HAL-function with normal STM32duino-code???
Return value is 0 (HAL_StatusTypeDef = HAL_OK) Another thing I have to serach for the right file ...
again I'm using a STM32G0B1CBT6-board.
At VBAT-pin two NiMH-rechargables are connected, so ≈ 2,6 V.
First I used the simpleRTC-example to see, how accuracy is with LSE crystal.
During the first 10 minutes RTC is 11 ms too slow - comparing to timestamp of PC.
I let it run over night for 12 hours and can estimates, that RTC will be 1,5 s too slow in 24 hours. That's 17,4 ppm and inside range from datasheet.
I like to adjust RTC.
Reference manual tells me something about CALP and CALM.
And I found HAL_RTCEx_SetSmoothCalib() inside stm32g0xx_hal_rtc_ex.c ...
But it looks like it has no effect.
RTC is never going faster.
Can I mix this HAL-function with normal STM32duino-code???
Return value is 0 (HAL_StatusTypeDef = HAL_OK) Another thing I have to serach for the right file ...
Code: Select all
#include <STM32RTC.h>
#include <stm32g0xx_hal_rcc_ex.h>
uint8_t ret;
RTC_HandleTypeDef hrtc;
STM32RTC& rtc = STM32RTC::getInstance();
uint64_t t = 0;
void setup() {
Serial.begin(9600);
delay(2000);
Serial.print("\n\n ----- RTC smooth calibration mit STM32G0B1CBT6 ----- \n");
rtc.setClockSource(STM32RTC::LSE_CLOCK);
rtc.begin(false,STM32RTC::HOUR_24);
ret = HAL_RTCEx_SetSmoothCalib(&hrtc, RTC_SMOOTHCALIB_PERIOD_32SEC, 1, 500);
Serial.printf("ret = %d \n",ret);
}
void loop() {
if (millis() - t > 29999) {
Serial.printf("%02d.%02d.%02d ", rtc.getDay(), rtc.getMonth(), rtc.getYear());
Serial.printf("%02d:%02d:%02d.%03d\n", rtc.getHours(), rtc.getMinutes(), rtc.getSeconds(), rtc.getSubSeconds());
t = millis();
}
}