I am using a ATtiny817 xplained Mini, I want to toggle LED using overflow interrupt for every 10 sec from RTC, but i am not able generate the interrupt. Is the configurations correct?
I have configured the Main clock source 32kHz (Low Power Oscillator), using 1KHz from it to clock the RTC with no prescaler.
#define RTC_SAMPLE_PERIOD (1024*10)
void RTC_init(void)
{
/* Configuring the Clock Source */
_PROTECTED_WRITE(CLKCTRL.OSC32KCTRLA, CLKCTRL_RUNSTDBY_bm);
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLB,!CLKCTRL_PEN_bm);
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLA,!CLKCTRL_CLKOUT_bm | CLKCTRL_CLKSEL_OSCULP32K_gc);while(!(CLKCTRL.MCLKSTATUS & CLKCTRL_OSC32KS_bm));
/* Initialize RTC */while(RTC.STATUS >0);//Wait for All registers to be Synchronized
/* Set Period */
RTC.PER = RTC_SAMPLE_PERIOD;
/* Configuring RTC CLOCK */
RTC.CLKSEL = RTC_CLKSEL_INT1K_gc;//Selecting 1kHz from 32KHz Low Power Oscillator (OSCULP32K)
/* Run in debug: enabled */
RTC.DBGCTRL |= RTC_DBGRUN_bm;
RTC.CTRLA = RTC_RTCEN_bm /* Enable: enabled */| RTC_RUNSTDBY_bm;/* Run In Standby: enabled */
/* Enable Overflow Interrupt */
RTC.INTCTRL |= RTC_OVF_bm;
}
ISR(RTC_CNT_vect)
{
LEDupdateFlg=1;
RTC.INTFLAGS |= RTC_OVF_bm;
}
I have configured the Main clock source 32kHz (Low Power Oscillator), using 1KHz from it to clock the RTC with no prescaler.
#define RTC_SAMPLE_PERIOD (1024*10)
void RTC_init(void)
{
/* Configuring the Clock Source */
_PROTECTED_WRITE(CLKCTRL.OSC32KCTRLA, CLKCTRL_RUNSTDBY_bm);
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLB,!CLKCTRL_PEN_bm);
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLA,!CLKCTRL_CLKOUT_bm | CLKCTRL_CLKSEL_OSCULP32K_gc);while(!(CLKCTRL.MCLKSTATUS & CLKCTRL_OSC32KS_bm));
/* Initialize RTC */while(RTC.STATUS >0);//Wait for All registers to be Synchronized
/* Set Period */
RTC.PER = RTC_SAMPLE_PERIOD;
/* Configuring RTC CLOCK */
RTC.CLKSEL = RTC_CLKSEL_INT1K_gc;//Selecting 1kHz from 32KHz Low Power Oscillator (OSCULP32K)
/* Run in debug: enabled */
RTC.DBGCTRL |= RTC_DBGRUN_bm;
RTC.CTRLA = RTC_RTCEN_bm /* Enable: enabled */| RTC_RUNSTDBY_bm;/* Run In Standby: enabled */
/* Enable Overflow Interrupt */
RTC.INTCTRL |= RTC_OVF_bm;
}
ISR(RTC_CNT_vect)
{
LEDupdateFlg=1;
RTC.INTFLAGS |= RTC_OVF_bm;
}