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?
Addition
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.
OSC_CTRL |= OSC_XOSCEN_bm;
while(!(OSC_STATUS & OSC_XOSCRDY_bm));
CCP = CCP_IOREG_gc;
CLK_CTRL = (CLK_CTRL & ~CLK_SCLKSEL_gm) | CLK_SCLKSEL_XOSC_gc;
OSC_CTRL &= ~OSC_RC2MEN_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.