Hi. I try to write a code that toggles on and off the leds on the bord using a rtc interrupt:
-first led toggles at every 100 ms
-second led toggles at every 1 second
-third led toggles at every 1 minute
-forth led toggles at every 1 h.
Can anyone tell my what I did wrong? It doesn't enter in the interrupt and doesn't sets the flag(sometimes sets the flag but it still doesn't enter in the interrupt routine).
This is my code:
void intrerupere()
{
milisec++;
if(milisec==100)
{
if(SIU.GPDO[68].R == 0)
{
SIU.GPDO[68].R = 1;
sec++;
}
else
{
SIU.GPDO[68].R = 0;
sec++;
}
milisec=0;
}
if(sec == 10)
{
if(SIU.GPDO[69].R == 0)
{
SIU.GPDO[69].R = 1;
min++;
}
else
{
SIU.GPDO[69].R = 0;
min++;
}
sec=0;
}
if (min == 60)
{
if(SIU.GPDO[70].R == 0)
{
SIU.GPDO[70].R = 1;
h++;
}
else
{
SIU.GPDO[70].R = 0;
h++;
}
min=0;
}
if (h == 60)
{
if(SIU.GPDO[71].R == 0)
{
SIU.GPDO[71].R = 1;
}
else
{
SIU.GPDO[71].R = 0;
}
h=0;
}
RTC.RTCS.B.RTCF=1;
}
void init_rtc(void)
{
RTC.RTCC.B.CNTEN=0;
RTC.RTCC.B.RTCIE=1;
RTC.RTCC.B.FRZEN=0;
RTC.RTCC.B.ROVREN=0;
RTC.RTCC.B.RTCVAL=0x64;
RTC.RTCC.B.APIEN=0;
RTC.RTCC.B.APIIE=0;
RTC.RTCC.B.CLKSEL=2; //16 MHz, 1 ms resolution
RTC.RTCC.B.DIV512EN=1;
RTC.RTCC.B.DIV32EN=1;
RTC.RTCC.B.CNTEN=1;
RTC.RTCS.B.RTCF=1;
}
void main (void)
{
EXCEP_InitExceptionHandlers();
INTC_InitINTCInterrupts();
initModesAndClock(); /* Initialize mode entries and system clock */
initPeriClkGen(); /* Initialize peripheral clock generation for DSPIs */
disableWatchdog(); /* Disable watchdog */
INTC_InstallINTCInterruptHandler(&intrerupere,60,15);
init_rtc();
SIU.PCR[68].R=0x0200;
SIU.PCR[69].R=0x0200;
SIU.PCR[70].R=0x0200;
SIU.PCR[71].R=0x0200;
INTC.CPR.B.PRI=0;
asm(" wrteei 1");
while (1)
{
;
} /* Wait forever */
}
Thanks!