LSE RTC crystal drift

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
Post Reply
geologic
Posts: 10
Joined: Thu Dec 15, 2022 10:12 am
Answers: 1

LSE RTC crystal drift

Post by geologic »

Hi all

I made a custom board based on STM32L052C8T6 with a 32.768Khz crystal (ABS05-32.768kHz-T) and 2x15pF caps.
I uploaded simpleRTCAlarm example that fires an alarm every 60 second. If i use the LSI every alarm fires around 58 seconds (measured with my stopwatch). But if i use the LSE every alarm takes around 75 seconds, that's a 15 seconds drift.

ABS05-32.768kHz-T has 12.5pF of load capacitance, considering 5pF for stray capacitance i calculated 15pF for the crystal caps.
Is this configuration ok? Could be a defective crystal? Any other idea?

Thanks
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: LSE RTC crystal drift

Post by fpiSTM »

Seems very big drift while LSE should be more precise than LSI.
If you are able to test with a second one I guess it should be fine.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: LSE RTC crystal drift

Post by ag123 »

75 secs in a minute is a pretty large drift, it would take checking that all the configurations (in particular for the registers) are correct say for a 32k crystal.
if indeed all configs are correct, then it is likely that the crystal isn't after all running at 32khz but some other frequency.

for moderate drifts, i've tried correcting them in stm32f103 with the 'old roger's core'
https://github.com/rogerclarkmelbourne/ ... /RTCAdjust
unfortunately, I've not ported it to the current core.

In my case, I've a 32k crystal that drifts by about like 10 to 15 minutes each month. This is more than can be offset in hardware.
What I did is to take measurements over say several days, and compute the drift against manually updated clock time.
then on each reset it adds the computed drift since the last adjustment.

In your case, if the crystal is after all not 32k, but some other frequency. it is probably better to change the crystal.
otherwise, you would need to attempt to calibrate, measure the frequency of your crystal and set the divisors appropriately so as to compensate for a crystal that is after all not running at 32k.

there is a strange feeling that some 'cheap' 'crystals' may not be actually precision quartz, and instead they could be some other ceramic resonator materials e.g. rochelle salt, pzt etc. i've not really tried or had a real 'epson' ones from japan, guess those would be expensive :lol:
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: LSE RTC crystal drift

Post by dannyf »

I'm looking at a chip (that shall remain nameless) where the LSE is dead on with the internal rc oscillator and runs much faster when the main xtal oscillator is used. :)

I would suggest if you run the chip on HSI and see if the crystal is accurate.

double check your caps (value + connection); double check your pcb traces...
geologic
Posts: 10
Joined: Thu Dec 15, 2022 10:12 am
Answers: 1

Re: LSE RTC crystal drift

Post by geologic »

I tried with different cap values but didn't make any difference.
Last i changed the crystal and LSI start working, so the problem was a bad/defective crystal.

Thank's all for your help.
Post Reply

Return to “Custom design boards”