We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
Why lpc2378's doc states that An interrupt is generated on every 16/32/64/etc. counts of the Clock Tick Counter and I have 16/32/64/ with Simulator and 32/64/128 with real chip ?
#include "LPC23xx.H" #define ILR_RTCCIF 0x01 #define ILR_RTCALF 0x02 #define ILR_RTSSF 0x04 #define CCR_CLKEN 0x01 #define CCR_CTCRST 0x02 #define CCR_CLKSRC 0x10 int nclock = 0, nclocks = 0, t0=0, dt0=0; volatile int alarm_on = 0; __irq void RTCHandler (void) { RTC_ILR |= ILR_RTSSF; alarm_on = 1; VICVectAddr = 0; /* Acknowledge Interrupt */ } int stat[256]; int main (void) { int i, dtmin, dtmax; for(i=0;i<256; i++) stat[i]=0; /*--- Initialize registers ---*/ RTC_AMR = 0; RTC_CIIR = 0; RTC_CCR = CCR_CTCRST; RTC_CCR = CCR_CLKSRC; VICIntSelect = 0x00000000; VICVectAddr13 = (unsigned) RTCHandler; VICVectCntl13 = 0x00000013; /* Set channel =RTC */ VICIntEnable = (1<<13); /* Enable the interrupt */ /*--- Start RTC counters ---*/ RTC_CCR |= CCR_CLKEN; RTC_ILR = ILR_RTCCIF; RTC_CISS = 0x81; //subsecondes interrupt enable 0x80 = 488 mks, 0x87 = 62.5 ms t0 = RTC_CTC; dtmax = 0; dtmin = 1000000; while (1) { /* Loop forever */ nclocks++; if ( alarm_on != 0 ) { dt0 = RTC_CTC - t0; t0 = RTC_CTC; // RTC_CISS = 0x80; //Simulator: dtmin = 0x20 dtmax = 0x20 RTC_CISS = 0x80; stat[]= 0,0,0,0..... stat[16] = big value //JTAG debug: dtmin = 0x0 dtmax = 0x20 RTC_CISS = 0x80; stat[]= 1,0,1,0..... stat[32] = big value // RTC_CISS = 0x81; //Simulator: dtmin = 0x40 dtmax = 0x40 RTC_CISS = 0x80; stat[]= 0,0,0,0..... stat[32] = big value //JTAG debug:dtmin = 0x0 dtmax = 0x40 RTC_CISS = 0x80; stat[]= 1,0,1,0..... stat[64] = big value if(dt0 >= 0) { if(dt0 > dtmax) dtmax = dt0; if(dt0 < dtmin) dtmin = dt0; if(dt0<256) stat[dt0]++; } alarm_on = 0; nclock++; } } return 0; }