Page 1 of 1

Capture Custom Interrupt Code

Posted: Mon Sep 09, 2019 3:44 pm
by Dave Squibb
Hello all,
I am trying to use the two Capture modules CCP1 and CCP2 on a PIC18F2550 to measure the time difference between two pulses. The rising edge of the first on CCP1 clears Timer 1 and the rising edge
on CCP2 saves Timer 1 value to variables HIGH and LOW. This value is sent out over UART1.

In practice 0x00 is sent out on UART1 at 1mS intervals until the first pulse is received. UART1 output then ceases. The interrupt looks like it is being called but not cleared. This should be done in the Interrupt Handler code.

Could someone have a look please?
CCP.fcfx
(15.52 KiB) Downloaded 222 times

Re: Capture Custom Interrupt Code

Posted: Tue Sep 10, 2019 11:38 am
by Benj
Hello,

The Timer component under Data might be an option for you to avoid CCP complications.

I'll have a look at your program for you.

Re: Capture Custom Interrupt Code

Posted: Tue Sep 10, 2019 1:37 pm
by Dave Squibb
Thanks Benj, that would be good.
Dave.

Re: Capture Custom Interrupt Code

Posted: Wed Sep 11, 2019 11:12 am
by Dave Squibb
Have you had a chance to look at this yet Benj?
Thanks,
Dave.

Re: Capture Custom Interrupt Code

Posted: Wed Sep 11, 2019 3:09 pm
by Benj
Hi Dave,

I had a look and didn't spot anything obvious. Have you tried the timer component to see if that will do what you need?

Re: Capture Custom Interrupt Code

Posted: Sat Sep 14, 2019 11:18 am
by Dave Squibb
Hi Benj,
The Timer component works well in this instance because the code is doing nothing else at this point so I can poll the 2 inputs for a change of state. The CCP code has the advantage of edge triggered interrupts. (INT pins are tied up with other things)
Dave.