Deha908
Newbie level 3
Hi,
I am using a PIC18F4520 and I am having difficulty using the CCP module. I am trying to capture a clock signal so I am using the Capture function of the module. I have the module set up to run off of TMR3. I also have the CCP1 pin set as an input. The interrupt for the capture works correctly in that the flag is set when the clock input goes from low to high; however the value in the CCPR1 register continues to change while the input is high. So instead of capturing the rising edge of the input, CCPR1 changes with TMR3 while the input is high. So, when I read CCPR1 in the interrupt, the interrupt latency is included in the time value that I read from CCPR1.
I have read the sections of the data sheet many times and I know how the module should work, but I can't seem to work it properly.
I also have a problem with using the compare module. I have everything set up correctly to toggle the output pin on a match. The interrupt is generated correctly when TMR3 is equal to CCPR2; however the CCP2 pin does not toggle and I have to do this manually in the interrupt which makes the signal inaccurate.
Does anyone have any ideas?
Thanks!
I am using a PIC18F4520 and I am having difficulty using the CCP module. I am trying to capture a clock signal so I am using the Capture function of the module. I have the module set up to run off of TMR3. I also have the CCP1 pin set as an input. The interrupt for the capture works correctly in that the flag is set when the clock input goes from low to high; however the value in the CCPR1 register continues to change while the input is high. So instead of capturing the rising edge of the input, CCPR1 changes with TMR3 while the input is high. So, when I read CCPR1 in the interrupt, the interrupt latency is included in the time value that I read from CCPR1.
I have read the sections of the data sheet many times and I know how the module should work, but I can't seem to work it properly.
I also have a problem with using the compare module. I have everything set up correctly to toggle the output pin on a match. The interrupt is generated correctly when TMR3 is equal to CCPR2; however the CCP2 pin does not toggle and I have to do this manually in the interrupt which makes the signal inaccurate.
Does anyone have any ideas?
Thanks!