I'm trying to get the RTC to work. I'm using code out of the example rtc_example.c and rtc_driver.c The RTC.CNT register never changes and interrupt never occurs. I've tried the ULP clock source and the ROSC sources. I've tried setting the prescaler directly... I'm wondering if anyone else figured this out or had similar problems.
/* Turn on internal 32kHz. */ OSC.CTRL |= OSC_RC32KEN_bm; do { /* Wait for the 32kHz oscillator to stabilize. */ } while ( ( OSC.STATUS & OSC_RC32KRDY_bm ) == 0); /* Set internal 32kHz oscillator as clock source for RTC. */ CLK.RTCCTRL = CLK_RTCSRC_RCOSC_gc | CLK_RTCEN_bm; do { /* Wait until RTC is not busy. */ } while ( RTC_Busy() ); /* Configure RTC period to 1 second. */ RTC_Initialize( RTC_CYCLES_1S, 0, 0, RTC_PRESCALER_DIV1_gc ); /* Enable overflow interrupt. */ RTC_SetIntLevels( RTC_OVFINTLVL_LO_gc, RTC_COMPINTLVL_OFF_gc ); /* Enable interrupts. */ PMIC.CTRL |= PMIC_LOLVLEN_bm; sei(); while(true) { printf_P(PSTR("\r\nrtc: %04x"), RTC.CNT); } ISR(RTC_OVF_vect) { rtc_tick=1; //PORT_TogglePins( &PORTQ, PIN2_bm ); PORTQ.OUT ^= (1<<2); }