Electrical – xmega external crystal won’t stabilize


I'm using an ATxmega64A3U, I've connected a 4MHz external crystal and two 18pF load caps. I'm using the ASF module for clock configuration, however when starting up I can see that the code hangs in the following spot:

static inline void osc_wait_ready(uint8_t id)
    while (!osc_is_ready(id)) {
        /* Do nothing */

The while waits for the clock source to stabilize but that never happens. Does anyone have any suggestions why this could be?


The code I've posted above is from the ASF, to make sure I know what I'm executing I wrote the following code and could see that the code gets stuck in the while loop that waits for the oscillator to stabilize.

while(!(OSC_STATUS & OSC_XOSCRDY_bm));

I enable the external oscillator, wait for it to get stable, disable lock on register, switch over to external oscillator, disable internal 2MHz oscillator.

Best Answer

Note that 18pF load capacitance from the data sheet does not mean to put two 18pF capacitors on the board.

Its the total capacitance the crystal should "see". Assuming a stray capacitance of 5pF, you would have

Cl = (18pF*18pF)/(36pF) + 5pF = 14pF

You may want to try something like 24pF for the load capacitors.

Furthermore, the ESR of the crystal you choose it pretty high. This may become an issue if the oscillator circuit cannot adequately drive the crystal.

Higher frequency crystal tend to have lower ESR, so try a crystal with 8 or 16MHz from that series.