Skip to main content
Ofaro.1
Associate III
October 18, 2022
Solved

Slow RTC

Hi all,

I'm using STM32F429 on a custom board which is running a TFT LCD and RTC is running slow compared to the computer clock. 8MHz crystal is connected to HSE but currently, LSE is using an internal clock. My question is:

Can I connect the external crystal to LSE pins to get accurate RTC or do I need to connect the second crystal to it?

Please see attached pictures.

Any other suggestions will be very helpful, I'm badly stuck here.

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
October 18, 2022

> LSE is using an internal clock.

There is no such thing. According to the picutres, are using LSI, which is an imprecise RC oscillator.

Use the divided HSE as RTC clock. You will need to change the RTC dividers accordingly.

0693W00000UoFxnQAF.png 

JW

8 replies

waclawek.jan
waclawek.janBest answer
Super User
October 18, 2022

> LSE is using an internal clock.

There is no such thing. According to the picutres, are using LSI, which is an imprecise RC oscillator.

Use the divided HSE as RTC clock. You will need to change the RTC dividers accordingly.

0693W00000UoFxnQAF.png 

JW

Ofaro.1
Ofaro.1Author
Associate III
October 20, 2022

Thanks waclawek for putting me in the right direction.

Just to confirm one thing more, once HSE freq (8MHz) is divided by 8, which gives 1 MHZ. So, in order to run the RTC Do I need to set the Asynchronous and synchronous predivider values from the RTC parameter settings to get 32.768KHz?

Many thanks

waclawek.jan
Super User
October 20, 2022

> Do I need to set the Asynchronous and synchronous predivider values from the RTC parameter settings to get 32.768KHz?

No. Normally, you set those two values to get 1Hz from 32.768kHz, now you have to change them to get 1Hz from 1MHz.

JW

Ofaro.1
Ofaro.1Author
Associate III
October 20, 2022

I have done that and for the first 5 minutes it was exactly according to RTC but then gradually there's a second difference. It showing 27mins 49s while on the stopwatch it's 28mins 0s. I have attached pics for your review.

Ofaro.1
Ofaro.1Author
Associate III
October 20, 2022

..

waclawek.jan
Super User
October 20, 2022

Read out and check/post RTC registers content. Note, that prescalers' value in register has to be one less than the value used for calculation:

0693W00000UoQwkQAF.pngso in the register you should see 124 and 7999.

I don't use Cube/CubeMX so I don't know how do the values you put in CubeMX translate to the registers.

JW

Ofaro.1
Ofaro.1Author
Associate III
October 20, 2022

Much appreciated your help.

With 125-1 and 8000-1, it works exactly according to RTC.

But I have another custom board with this 8MHz crystal (MC306-G-06Q-32.768) but somehow that one is lagging by 4s. Both crystal's specs are the same. One that works fine is this crystal (7A-8.000MAAJ-T).

Many thanks