Hi,
I am experimenting with using the 16F876A to measure the turn off time of a phototransistor. I have tried two ways, just to see how much difference there would be in the time. The first way is using the RB0 input to generate an interrupt, and the 2nd is using the capture feature on pin RC2/CCP1.
1st method:
1. Turn off the LED that points at the phototransistor
2. Reset the timer1 high and low bytes to zero
3. When program jumps to ISR, read value of Timer 1. Result is 204uS
2nd method:
1. Turn off the LED that points at the phototransistor
2. Reset the timer1 high and low bytes to zero
3. Poll the CCP1IF flag in a loop until it goes high, and then read the value of the CCP1 high and low byte registers. Result is 188uS, which is almost exactly the same as I measure on an oscilloscope.
With 2nd method, I had expected to do it the same way as the first... I thought program would jump to ISR when pin RC2 went high, but it did not work. So my question is, why doesn't the program jump to the Interrupt handler when the CCP1IF flag gets set? If it did then I would not need to poll the pin in a loop. Would I be doing something wrong or is that how it is supposed to work? Thanks for any answers.
Bookmarks