I am trying to use PIC18F452 to read an optical encoder at a very low frequency (less than 100 Hz). I have tried three approaches:
-Using the CCP module to capture the rising edge and calculate the time between them to determine the period. This didn't work - The interrupt handler was never called
-Using polling: This worked in a way, but the time varied erratically and the result made no sense at all.
-Using the RBIF interrupt on port B -this works better than polling, but even then the result varies wildly.
The program also drives a seven segment display and reads an analogue input periodically.
I haven't been able to figure out what is wrong. Please help!
Thank you for reading.
-Using the CCP module to capture the rising edge and calculate the time between them to determine the period. This didn't work - The interrupt handler was never called
-Using polling: This worked in a way, but the time varied erratically and the result made no sense at all.
-Using the RBIF interrupt on port B -this works better than polling, but even then the result varies wildly.
The program also drives a seven segment display and reads an analogue input periodically.
I haven't been able to figure out what is wrong. Please help!
Thank you for reading.