Hi All, I am trying to read RTC data in interrupt routine and display the data on PC through RS232.
I always get interrupt every 16.40ms, and RTC data (hour, min and sec) is 0 (no increment).
Following are my RTC initilization and ISR codes, please help me to solve the problem.
Thanks
Jack
<prer> void initial_rtc(){ CCR = 0x13; /* Reset the clock ,clock from external osc,RTC enable*/ ILR =0x01; /* Clear the RTC Interrupt */ CCR |=0x01; /* RTC reset changeed to 0 */ CIIR = 0x01; /*interrupt on Second counter*/
VICVectAddr13 = (unsigned long)read_rtc;/*Set Interrupt Vector*/ VICVectCntl13 = 15; VICIntEnable = (1 << 13); }
__irq void read_rtc(void){ int hour = 0; int min = 0; int sec = 0; //Clear Interrupt ILR |= 1; //Read Time registers hour = (CTIME0 & MASKHR)>>16; //MASKHR:0x1f0000 min = (CTIME0 & MASKMIN)>>8;//MASKMIN:0X3F00 sec = (CTIME0 & MASKSEC); // MASKSEC:0X3F printf("\nTime is%02d:%02x:%02d",hour,min,sec); //toggle LED0 on MCB2300 board to masure interrupt Frq. RTC_Flag ++; if (RTC_Flag == 1) LED_On (0); if (RTC_Flag == 2) {LED_Off (0); RTC_Flag = 0; } //updateing VIC VICVectAddr = 0;
}
Hi Vektor, The result is the same as mine-- too many interrupts in 1 sec, but RTC data updated is ok. when I added CISS = 0 in initial_rtc(), your code works, same thing done in my code, it works also, interesting!! Question is: in your code, "VICVectCntl13 |= 0x20 | VIC_RTC;" what does "0x20" mean?
About 0x20 (bit 5=IRQslot_en) in VicVectCntl13 :
From Manual : "When 1, this vectored IRQ slot is enabled, and can produce a unique ISR address when its assigned interrupt request or software interrupt is enabled, classified as IRQ, and asserted."
About the interrupt handler:
void rtc_int(void) __irq { if(ILR_BITS.RTCCIF) { ILR |= 1; // Put code here } if(ILR_BITS.RTCALF) { ILR |= 2; // Put code here } VICVectAddr = 0; }
Hi Vektor, Thank you very much for your help. Have a good day. Jack