View previous topic :: View next topic |
Author |
Message |
jmb1539
Joined: 29 Mar 2010 Posts: 11
|
PIC18F2620 CCP Double Edge Triggering |
Posted: Tue Jun 08, 2010 11:41 am |
|
|
I'm using a PIC18F2620 to measure a frequency of an incoming signal consisting of a 5V - 0V square wave. My CCP1 is setup for capture mode falling edge detection. While running, I'm getting an occasional interrupt on the falling edge (as I should) and the rising edge (should not happen) of the incoming signal. Sometimes this happens more frequently, and at other times it happens less frequently. I verified the double edge triggering by toggling an output every time the interrupt is generated and observing it on a scope.
Has anyone seen this before or read about it in any errata? Does anyone know a work around?
Thanks,
JuBo |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 08, 2010 12:16 pm |
|
|
How clean is the input signal ? Does it have noise on the edges ?
You could put in an RC filter (low pass) to remove the noise.
Try the circuit below. This gives a cutoff frequency of 159 KHz.
You didn't say what your input signal frequency is. But I think
this would be worth trying, at least initially.
Code: |
signal 100 ohms
from ----/\/\/\/-----o----------> To CCP pin on PIC
device |
|
----- 10 nf
----- (.01 uf)
| capacitor
|
-----
--- ground
-
|
|
|
![](templates/subSilver/images/spacer.gif) |
jmb1539
Joined: 29 Mar 2010 Posts: 11
|
|
Posted: Thu Jun 10, 2010 8:46 am |
|
|
My frequency input is in the range of 3-50Hz. It was a bit unstable, so I passed it through a schmit trigger to square off the signal. This really cleaned it up, but I was still getting a trigger on both edges of the input signal. I went and installed a 70Hz RC filter on the output of the schmit trigger and this really seems to have stabilized the interrupts. I guess there was enough instability on the schmit trigger transition that it caused an interrupt to be serviced by the PIC. Once again, thanks for your help.
JuBo |
|
![](templates/subSilver/images/spacer.gif) |
|