cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Accuracy - STM32L475

dtarrago
Associate II
Posted on August 29, 2017 at 14:43

According to pre-fixed parameters when setting up the RTC (PREDIV_A=127m PREDIV_S=255) and in accordance with AN4759, if I use a reccomended 32.768KHz (LSE) crystal, I should have a 512Hz signal at PC13 pin (STM32L475) when setting up RTC-Calendar and this pin is enabled as a calibration output.

I have tested this signal with two different PCB's (four layer boards) and with also two different recommended crystals, and I measure a signal (PC13) that is quite below 512Hz:

- In one of the boards, I had to fix PREDIV_A to 125 in order to get 512Hz (With default values, signal ouput is 504Hz).

- In the second board, PREDIV_A has to be set to 126 to get a 512Hz signal (508Hz with default values).

Furthermore, this error is noticed in the RTC calendar itself: delays of a few seconds in just two hours!!!!!

In both cases, RTC-Calendar and calibration output have been set up by means of Cube.

According to this behaviour, this would mean that the crystal is oscillating at about 300Hz difference, what is quite a huge difference!!!!

We have also tested different load capacitors with both tested crystals and the results are quite similar (by default, we had 5p6 capacitors, but last test was with 3p3 capacitors and result was the same).

Finally, and what is the most amazing thing: if the STM32L4 is replaced with a STM32F103, the RTC delay disappears!!!

Do you know which can be the reason of the problem related with this RTC unaccuracy??

#stm32l4 #lse #rtc
14 REPLIES 14
Posted on August 29, 2017 at 14:58

What's the content of RCC_BDCR?

JW

Posted on August 29, 2017 at 15:02

Hello!!

>>> We have also tested different load capacitors with both tested crystals and the results are quite similar (by default, we had 5p6 capacitors, but last test was with 3p3 capacitors and result was the same).

Check  that the source for RTC is LSE and not LSI.

It is very extreme for a 32768 crystal to have such inaccuracy.

Regards. .

Vf

AVI-crak
Senior
Posted on August 29, 2017 at 15:20

RM0395 Reference manual, page 243, Backup domain control register (RCC_BDCR), Bits 4:3 LSEDRV[1:0] LSE oscillator drive capability.

It is necessary to increase the value of this register.

The LSE generator can reduce the voltage swing on the quartz generator - to save energy and the life of the quartz itself. But at the same time, the contacts and the body of quartz become a good antenna, with a high sensitivity to interference. The case of quartz must have contact with the ground - this will reduce the level of interference.
Posted on August 29, 2017 at 15:21

Pretty sure the L4 has different drive circuitry than the old F1. Most should deliver ppm accuracy if correctly implemented.

Do you have datasheets for the *specific* crystals that you purchased? ie fully qualified part#

Are these 6, 9 or 12pF crystals?

I have a couple of L4 boards with LSE, will benchmark against GPS when I get a chance.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 29, 2017 at 15:20

Hello,

Here you have a screenshot (debugging session) showing this register as well as the initialization code and a second image where Cube clock configuration is also shown.

Best regards.

0690X000006042yQAA.jpg0690X0000060433QAA.jpg
Jaroslav BECKA
ST Employee
Posted on August 29, 2017 at 18:36

Hello Daniel, 

the issue may be also hidden in the PCB layout.

It is important to ensure that no signal tracks lead through the crystal area from both sides of the PCB.

The oscillator circuit is very sensitive to interference.

Especially high frequency signals of communication interfaces or LCD signals can disturb the oscillations and cause inaccuracy of the crystal. 

The LSCO feature allows to output directly the LSE frequency on dedicated pin (PA2).

Using this feature, accuracy of LSE clock can be verified.

Posted on August 29, 2017 at 17:23

It is a 6pF crystal.

Please, find enclosed its datasheet.

Furthermore, I have already modified LSE Drive to 'Higher Driver Capability' and result is the same....

Best regards.

0690X00000603u9QAA.jpg
Posted on August 30, 2017 at 12:04

Hello,

I summarize here below our current status with this issue:

- For the pcb we have been talking about, we have sensed LSE frequency (pin PA2) and read frequency is about 32.518KHz.

- We have just received a different pcb (based on same micro) and we have tested it: in this case, the read frequency at PA2 pin is correct. Being in this situation, we have also enabled PC13 for the 512Hz calibration output --> this makes the PA2 to be 32.5KHz and PC13 is about 508Hz. In the same situatiuon, if 512Hz output is mapped to PB2 (instead of PC13), then we get 32.1768KHz (PA2) and 512Hz (PB2). So, it seems that PC13 is coupled with crystal IN/OUT when it is enabled as a calibration ouput.

Apart of this, and in order to guess what it is happening with the first pcb, please find here below a screenshot of both pcbs: the one we have been talking about and the second one, where crystal is working fine. What is your opinion?

0690X000006084KQAQ.png0690X00000603uRQAQ.jpg

Best regards,

Dani.

Posted on August 30, 2017 at 15:41

VBAT is routed how?

JW