View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
PIC24EP512GP806 - Interrupt-on-change trigger on level? |
Posted: Thu Nov 24, 2022 9:08 am |
|
|
Device: PIC24EP512GP806
Compiler: 5.026
Hi again,
Is there a way to make the INT_CN interrupt on certain pins to trigger only on one edge transition? In other words, I'd like the interrupt to fire only when it changes from H_TO_L. Can I do this with the CN interrupts?
Thanks,
Ben |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Fri Nov 25, 2022 6:33 am |
|
|
Why not just use the external interrupts?. You have five on that chip.
Each can be mapped to pretty much any pin, and can be programmed to be
on either edge.
Interrupt capture captures a timer reading on the change. Not a simple
interrupt.
Problem with INT_CN, is that all pins assigned to that interrupt will go to
the same handler, and you will then have to poll to find which has changed.
These interrupt on any change from the last read state, not on levels.
You have five normal interrupts, why not use them?. |
|
![](templates/subSilver/images/spacer.gif) |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
|
Posted: Fri Nov 25, 2022 7:34 am |
|
|
Hi TTelmah,
The reason I am using INT_CN is because I am sampling 16 channels that can all generate an interrupt. For sure the EXT_INT would have been ideal but there's not enough.
I'll just have to do some filtering when the INT_CN is triggered.
Thanks for your time!
Ben
[EDIT] Not sure I have read this anywhere and I don't currently have the tools to test and I will be honest, I'm not sure exactly how to calculate this but what is the fastest signal that INT_CN can trigger on? My PIC is running at 129.024MHz (I overclock my 29.4912 external oscillator). I can successfully sample 16kHz I know that for a fact but the signal I am looking at sampling is a low pulse of 62.5us (16us) out of a 1kHz signal. Do you think this is doable?
------|________|---------------------------|________|--------
|<-16us->| (62.5kHz)
|<----------------1ms--------------->| (1kHz) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Fri Nov 25, 2022 9:05 am |
|
|
Several thousand times slower than the interrupt can handle.
Easy.
The problem will be polling the flags to see which pin has triggered and
handling that it will trigger on both edges. |
|
![](templates/subSilver/images/spacer.gif) |
|