Hello,

I'm struggling with a stupid problem for a while now and maybe someone has a good idea out there.

The goal is to record, for every high and low state of an incoming logic signal, its duration.

I'm capturing an incoming IR signal through a receiver module (i.e. TSOP32228) so I don't worry about the carrier frequency and the signal is "loud and clear" for the PIC (no bounce or any other disturbance).

Common IR remote protocols signals can last from 300µs up to around 10ms long.

Since I want to know how long each logic state (high and low) lasts, I first used RCTIME.

With this command, I easily measure half-a-pulse duration. Unfortunately, because of the power supply of the PIC (3V) and the max Xtal speed (8MHz), the resolution (5µs) doesn't permit a precision "good enough". With this method, a 300µs state (low or high) will return a RCTIME value between 50 and 70 which is around ±33% (!). By experience, acceptable values (< ±3%) can be measured starting with measures of incoming signals over 1ms.

I have also tried to "look" at a state change on a PORT. I made it with WHILE and with IF loops. The result is better but still not good enough especially for short signals (less than 1ms).

I then had a look to use INTERRUPTS, RB0/INT. Problem: I can catch only either the falling or the rising edge.

Same happens when I thought about using the Capture Mode of my PIC16LF88 where I have to choose either edge too.

Can anyone give me some advice on the best way for me to go?

Shall I change PIC with a higher Xtal frequency @ low voltage (like PIC16F1827)?

For sure, I don't want to buy an already-made self-learning universal IR remote!