I have an xmega192A3 with a 32.768kHz crystal on the TOSC pins. All i'm trying to do is get a 1Hz overflow interrupt.
My code:
// real time clock configuration sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC); //Wait until RTC is stable CLK.RTCCTRL = CLK_RTCSRC_TOSC_gc | CLK_RTCEN_bm; //CLK.RTCCTRL = CLK_RTCSRC_RCOSC_gc | CLK_RTCEN_bm; // this works while (RTC.STATUS & RTC_SYNCBUSY_bm); RTC.PER = 1023; RTC.CNT = 0; RTC.COMP = 0; /* Since overflow interrupt is needed all the time we limit sleep to * power-save. */ sleepmgr_lock_mode(SLEEPMGR_PSAVE); RTC.INTCTRL = RTC_OVFINTLVL_LO_gc; RTC.CTRL = RTC_PRESCALER_DIV1_gc; // RTC timer overflow ISR(RTC_OVF_vect) { LED_PORT.OUTTGL = LED1; }
This works fine for the internal oscillator, but the external crystal fails.
Any ideas?