We use an ADuC7060 to measure an external frequency in the range 0.1Hz to 2kHz. The capture interrupt do the job, but I have discovered that the difference between two consecutive captured values is always a multiple of 6, which means that the resolution is 6 time lower than expected. Why is it? Is it possible to improve it? Our application needs a high resolution.
Below is a piece of code. We use µVision3 V3.90.
Thank you in advance
POWKEY1 = 0x1;
POWCON0 = 0x78; // Set core to max CPU speed of 10.24Mhz
POWKEY2 = 0xF4;
T0CON = BIT17 + BIT16 + BIT10 + BIT8 + BIT7; // BIT17 = enable capture ; BIT16 event to monitor; BIT10 = Clock 10.24 MHz ; BIT8 = count up ; BIT7 = enable ; free running, No prescaler
IRQCONE = BIT5; // BIT5 = triggers on rising edge
IRQEN = BIT18; // BIT18 = activate XIRQ2 external interrupt.
IRQEN = BIT3; // Enable Timer 0 IRQ
// interrupt routine
void IRQ_Handler(void) __irq
if ((IRQSTA & BIT18) == BIT18) //XIRQ2 : pin P2.0/IRQ2/PWM0/EXTCLK
IRQCLRE = BIT18; // interrupt aknowledged
dwCapture = T0CAP;
dwPeriodeIn = dwCapture - dwCapturePrev; // allways a multiple of 6
dwCapturePrev = dwCapture;