Why not just let the timer/counter count your pulses?
MyCount VAR WORD
TMR1L=0 ' clear the low byte
TMR1H=0 ' clear the high byte
T1CON = %00000011 ' set Timer1 up as a hardware counter
This counts rising edge pulses on RC0. The count is held in TMR1L and TMR1H.
Do whatever you need to collect other data for 30 seconds then just read the count.
MyCount.LowByte = TMR1L
MyCount.HighByte = TMR1H
You could set Timer1 to overflow, count overflows incrementing a variable, but it would be
a lot easier using a built-in hardware counter. And it doesn't interrupt whatever else your
program is doing. It counts in the background.




Bookmarks