Other Parts Discussed in Thread: CC2530, CC2543
Hi,
I am trying to develop something which needs zero cross detection - I have a H11AA1 producing a pulse which is connected to P1_2 of the CC2530. When running the following code, I am getting inaccurate frequency reporting - it seems to only be picking up approx ~75 pulses / second (and this can fluctuate significantly), whereas it should be exactly 100 (50Hz).
Any suggestions would be very welcome.
Regards,
Ryan
P1DIR &= ~0x04;
P1SEL &= ~0x04;
PICTL &= ~0x02;
P1IFG &= ~0x04;
P1IF = 0;
P1IEN |= 0x04;
IEN2 |= 0x10; // P1IE = 1
EA = 1;
HAL_ISR_FUNCTION( halKeyPort1Isr, P1INT_VECTOR ) {
unsigned char p1ifg;
p1ifg = P1IFG;
P1IFG = ~p1ifg;
if (p1ifg & 0x04) {
freq_count = freq_count + 1;
PICTL &= ~0x02;
P1IFG = ~0x04;
}
P1IF = 0;
}