View previous topic :: View next topic |
Author |
Message |
eny
Joined: 15 Oct 2013 Posts: 1
|
PIC24F, Interrupts on RB4 and RB5 |
Posted: Sun Oct 27, 2013 5:12 am |
|
|
Hi,
I am quite new to programming with ccs compiler and i need some help.
I have a board with a PIC24FJ64GA002.
PIN RB4 and PIN RB5 are getting a short high pulse of 3µs length (for testing, the length should be variable)
I want to measure these length and to do it, I start a timer in the ISR.
This works fine, when both pulses don´t occur at the same moment.
So, i can only work with #INT_CNI?
With this ISR i can only see, if there is a change, but not on which pin and if falling or rising edge.
Is there another method to get it work?
Thanks |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Oct 27, 2013 9:17 am |
|
|
There's a better way by progamming two input capture modules to use the respective pins, provided
you have it still available in your application. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sun Oct 27, 2013 9:33 am |
|
|
Not just 'better', essential....
Even at the highest CPU clock rate, it still takes about a very large fraction of the pulse width to get into the interrupt, and this will vary.
The capture modules are the only way to make such a short measurement accurately. 'Why they are there'....
Best Wishes |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1346
|
|
Posted: Sun Oct 27, 2013 2:36 pm |
|
|
Definitely go with input capture.
As an informational note, if your application isn't as time sensitive and if the pins you select are reprogrammable (As these are), you can also assign external interrupts to them (EXT1-EXT4) and set them to trigger off of certain edges. You can even remap multiple interrupts to the same pin with different edge triggers. However, for the short timing you have, input capture is the way to go. |
|
|
|