I thought I would start a new thread since I hate those ones that go on and on and....
But this is really a continuation to my previous questions.
I am using the PIC18F27J13 and I want to catch some edges that are coming in at PIN 12/RC1/CCP8 which is a "Capture/Compare/PWM input/output".
I want to catch rising and falling edges and measure the time between each. So I am thinking that it will go something like this:
Set up a timer and get it running, like timer 1
Configure port C as an input for CCP8
Set for rising edge interrupt
When I get that interrupt save value of timer 1
change to falling edge
When I get that interrupt save value of timer 1
change to rising edge,
etc, etc
Then in my main loop do the math on the difference in the readings.
How does that sound?
I work with a guy who does Freescale code and he says the part he uses saves the timer value automatically so there is no interrupt latency. Can the PIC do this? I am guessing no but I don't know for sure.
Thanks
Now I want to catch some edges with a PIC...
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- opossum
- Posts: 636
- Joined: Fri Oct 26, 2007 12:42 am
Re: Now I want to catch some edges with a PIC...
In the ISR...
The capture register holds the value of the timer when the edge occurred, so interrupt latency and jitter is much less important.
There is a method to do 24 bit capture if you need more range without resolution loss.
- Calculate the difference between current capture and the previous - put in FIFO
- Save the current capture for use next time
- Change capture edge
- Clear CCP interrupt flag
- Return from ISR
The capture register holds the value of the timer when the edge occurred, so interrupt latency and jitter is much less important.
There is a method to do 24 bit capture if you need more range without resolution loss.
- zener
- Posts: 4567
- Joined: Sat Feb 21, 2009 2:38 am
Re: Now I want to catch some edges with a PIC...
Ahhh, capture register. So that is the same as Freescale then. So that all makes sense, and I know what a FIFO is. But in terms of my program how do I best implement that? I am guessing make an array and use a pointer. And I finally found IPR4 for the CCP interrupt priority.
Please be positive and constructive with your questions and comments.