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;
}