DIY FLL

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to try trimming the 32 MHz oscillator against GPS. No, it's not going to be as good as a GPSDO, but it's likely going to be better than the 32 kHz internal reference.

 

I've got TCC4+C5 set up as a 32 bit div1 counter and capture happening on the PPS pin. I expect the number of timer counts between adjacent PPS captures to be F_CPU. If it's low, I can nudge the frequency up, and if it's high, I can nudge it down. That's all I want to achieve here.

 

The question is what to do with the CALA and CALB registers. Do I increment or decrement one of them? Do I turn them both into a 13 value, increment or decrement that and then write it back out?

This topic has a solution.

Last Edited: Sat. Jul 1, 2017 - 12:04 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I took a closer look at the XMega E manual, and it appears the answer is to decrement/increment the CALA register as necessary and leave CALB alone.

Last Edited: Fri. Jun 30, 2017 - 06:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

FWIW, the behavior appears to be that the system will dither between two adjacent CALA values, with the resulting frequency shift being on the order of around 60-70 kHz (but fairly randomly distributed). Even if you assume a range of ±100 kHz that's still ±0.3%. Not terrible for something ostensibly not using a crystal.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So are you using DFLL with your GPS thingy as a reference?

 

The internal 32kHz should be within 0.3 % and if it isn't, you could adjust the calibration.  Of course the internal 32kHz will vary somewhat with temperature.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes. I'm just counting timer ticks between PPS pulses and nudging CALA up or down depending on the sign of the error. It seems to work as well as can be expected given the large adjustment granularity and mediocre stability of the oscillator. I could have just not bothered, but it's free given that it's got the GPS source already.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, the 32 MHz osc. isn't very stable.  The 32 kHz RC osc. is much more stable, and fairly accurate, out of the box.

 

I believe the 32 kHz osc. only varies by 1.0% from -40 to +40 Celsius.  The Xmega has a built-in temperature sensor.  It might be possible to get the temperature reading occasionally and adjust  the osc. accordingly.  I guess you'd have to custom calibrate each chip though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was happy with the 32 kHz oscillator and built-in DFLL. This was more or less an exercise to see if it was possible and what the result would be.

If I really needed to do better, I'd use something like a 10 MHz TCXO as an external source and use the PLL to triple that to 30 MHz.