cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Synchronous Pre-Divider

JScri.1
Associate

I am using an F4 discovery board and trying to using the included 8MHz HSE crystal to drive the RTC. I am using CubeMX to configure everything and I have configured the RTC to generate the calibration 1Hz signal that I am watching on a scope.

Initially I was using the LSI but the frequency is not very reliable so I thought the HSE would be better. The problem I have is that when I swap to the HSE the frequency of the calibration signal is way too high (about 32Hz instead of 1Hz). When selecting the HSE as the input for the RTC in CubeMX there is a divide by 8 and I have changed the Asynch predivider to 124 and the synch predivider to 7999 which should result in a 1Hz output. When testing in the debugger I can see that the values have been set correctly in the RTC PRER register.

What I have found is that changing the synch predivider is having no effect on the calibration signal. The divide by 8 that happens when selecting HSE for the RTC is configurable and changing this changes the the calibration signal frequency as expected though I don't know exactly how that part of it works.

Looking at the user manual and the RTC guide I can see that the calibration signal comes from the output of the synch predivider so I am at a loss as to why changing this value has no effect on the signal even though it is properly set in the RTC PRER register.

Any help or ideas would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

The calibration mode only works while the RTC is being clocked by the LSE.

There is another disadvantage to using the HSE as a clock source: it does not run continuously, e.g. stops in the event of a reset while the LSE continues to run.

Another hint: while using a DISCOVERY with 8MHz crystal you could change predivider and sync privider from 125-1/8000-1 to 32-1/31250-1. This allows a finer setting option, if you want to change the RTC accuracy by changing the sync predivider: 1/8000*86400 = +-10.8sec/day, 1/31250*86400 = +-2.765sec/day.

Good luck!

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Peter BENSCH
ST Employee

The calibration mode only works while the RTC is being clocked by the LSE.

There is another disadvantage to using the HSE as a clock source: it does not run continuously, e.g. stops in the event of a reset while the LSE continues to run.

Another hint: while using a DISCOVERY with 8MHz crystal you could change predivider and sync privider from 125-1/8000-1 to 32-1/31250-1. This allows a finer setting option, if you want to change the RTC accuracy by changing the sync predivider: 1/8000*86400 = +-10.8sec/day, 1/31250*86400 = +-2.765sec/day.

Good luck!

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

You should read the manual instead of just clicking in CubeMX, especially if it comes to anything out of the "usual", i.e. what CubeMX/Cube authors did not acount for.

IMO RM0090 in chapter RTC, subchapter Calibration clock output is quite clear in this regard:

If COSEL is set and (PREDIV_S+1) is a non-zero multiple of 256 (i.e: PREDIV_S[7:0] =

0xFF), the RTC_CALIB frequency is f RTCCLK /(256 * (PREDIV_A+1)).

JW