This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC2368 RTC initialization problem

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;

}

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

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

Children