cancel
Showing results for 
Search instead for 
Did you mean: 

RTC does not work correctly.

Andrej Balakin
Associate
Posted on May 13, 2018 at 06:09

Hello guys. I have a problem with RTC. (STM32CubeMX 4.25.1, STM32F103C8T6, )

On the penultimate version there was 1 error in the RTC code. But now added new mistakes.

hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND

It does not work. Now it starts only like this:

HAL_RTCEx_SetSecond_IT (& hrtc);

And besides, RTC works somewhere 30% slower, for 360 seconds, it manages to count only ~255 seconds. Earlier RTC worked without delays. How to fix the RTC delay?

ERROR:

LL_PWR_EnableBkUpAccess();

/* Enable BKP CLK enable for backup registers */

LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_BKP);

FIX:

HAL_PWR_EnableBkUpAccess();

/* Enable BKP CLK enable for backup registers */

__HAL_RCC_BKP_CLK_ENABLE();

ERROR:

hrtc.Instance = RTC;

if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) != 0x32F2){

hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;

hrtc.Init.OutPut = RTC_OUTPUTSOURCE_NONE;

FIX:

if (HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) != 0x32F2) {

sTime.Hours = 0;

sTime.Minutes = 0;

#!stm32-!cubemx-!rtc
1 REPLY 1
Andrej Balakin
Associate
Posted on May 14, 2018 at 13:15

Seems to be a problem in hardware, quartz is running at a very strange frequency :\