RC synk problem with crystal

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

Hello fellow freaks,

I got a problem with a ATXmega128A1. The AVR uses the internal 32 MHz RC and via the PLL continuously calibrates against an external 32 kHz crystal. The problem is that I get an offset and the offset is different for different units. It shows itself in the baud generation. At 38400 baud I get 2% timing error on one unit and 2.5% error on a other. It seems as the RC is not calibrated against the crystal. I'm I missing something in the initialization?

Kind regards
Björn Hilliges

void InitOsc(void) 
{
OSC.DFLLCTRL |= OSC_RC32MCREF_bm;    //Set up calibration reference to 32 KHz crystal
DFLLRC32M.CTRL |= DFLL_ENABLE_bm;    //Activate calibration reference.

OSC.DFLLCTRL |= OSC_RC2MCREF_bm;                  //Set up calibration reference to 32 KHz crystal
DFLLRC2M.CTRL |= DFLL_ENABLE_bm;                  //Activate calibration reference.

//  Set up system clocks.
OSC.CTRL     |= OSC_RC32MEN_bm;                  //Starting internal RC-net
while ( (OSC.STATUS & OSC_RC32MRDY_bm) == 0);     //Waiting for stabilization
                                                          
//  Switch to the PLL as the clock source 
ConfigurationChangeWrite(&CLK.CTRL, CLK_SCLKSEL_RC32M_gc);
} 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By setting RC2MCREF and R32MCREF to one, 32.768 kHz Crystal Oscillator connected to TOSC is selected as reference for calibration. Where is the code for activation of external 32.768kHz oscillator?

Ozhan KD
Knowledge is POWER

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

Yes, that seems to been the problem. Thanks for the help!

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

Btw, anyone else that happens to read this thread. Please note this from the ATXmega128A1 Errata:

Quote:
Both DFLLs and both oscillators have to be enabled for one to work