View previous topic :: View next topic |
Author |
Message |
carl
Joined: 06 Feb 2008 Posts: 240 Location: Chester
|
Interrupt on change |
Posted: Mon Jun 30, 2014 1:56 am |
|
|
Hi All,
Compiler Version: 4.141.
I am going to start a new project using a dsPIC30F for the first time - as I need a very fast application (and these go upto 30 MIPS). Previously I have only ever used PIC18's - so it is a big step up.
Anyway, my question is - I have looked at the various generic datasheets - and annoyingly it seems that the PIC30's so not have the interrupt on change feature (like the RB4-RB7) - can you concur?
If so, this is annoying - as i need that feature. I suppose looking at INTCON2 registor, I could use 2 x INT's (one positive and one negatove) for the same input - which would 'simulate' an interrupt on change - but this idea is messy.
I do not want to use a timer based interrupt.
Your thoughts would be much appreciated.
Thanks
Carl |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19482
|
|
Posted: Mon Jun 30, 2014 2:49 am |
|
|
Depends on the chip. Some have universal 'change' interrupts that can be programmed onto pins.
Look for chips with the 'input change notification module'. You select which pins it is to trigger on (OR the pin numbers with the enable).
Most have the module (can't think for now of one that doesn't).
INTR_CN_PIN in CCS.
Best Wishes |
|
|
carl
Joined: 06 Feb 2008 Posts: 240 Location: Chester
|
|
Posted: Mon Jun 30, 2014 2:59 am |
|
|
Hmmm,
Thanks for replying Ttelmah!
This would be good if I could find one.
Using the search option for my application (5V, 30 MIPS, 80 pin) on microchip only gives me five options (dsPIC30F5013,16, dsPIC30F6010A,13A,14A).
I am sure I checked - and they only have edge selectable interrupts.
I will check again and see.
Also though the actual explanation (and actual interrupt resistor) seems to only be in the generic series overview document DS70053C - and not the actual part specific datasheets.
Let me double check everything.
Thanks
Carl |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19482
|
|
Posted: Mon Jun 30, 2014 3:17 am |
|
|
Both those chips have the change module.
If you look at the chip 'block diagram', look for pins labelled 'CNxx'. These are the pins that can be selected for change notification.
It's a different 'approach' to the PIC16/18. A separate interrupt, rather than an interrupt on specific pins, and 'you' the user, select which pins are fed to it.
The individual pins only have edge selectable interrupts. |
|
|
carl
Joined: 06 Feb 2008 Posts: 240 Location: Chester
|
|
Posted: Mon Jun 30, 2014 3:32 am |
|
|
Hmmm,
I see it - thanks Ttelmah!
I haven't got a clue however how to set this up in code.
Have you any examples?
I'll have a look in the forum as well.
Thanks
Carl |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19482
|
|
Posted: Mon Jun 30, 2014 3:39 am |
|
|
ex_cni.c
|
|
|
carl
Joined: 06 Feb 2008 Posts: 240 Location: Chester
|
|
Posted: Mon Jun 30, 2014 3:47 am |
|
|
As always
Thanks so much!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19482
|
|
Posted: Mon Jun 30, 2014 4:55 am |
|
|
Unfortunately, if you want multiple pins, CCS don't quite handle this... :(
You need to use getenv, to get the addresses of the CNEN registers, and then set the bits in this for the CN inputs you want to trigger the change. OR-ing their pin numbers together just gives the wrong pin....
Not hard though, and using the getenv 'bit' ability, like:
CN15E = getenv("BIT:CN15E")
then gives you a 'bit' CN15E to enable/disable the notification on CN15. Just do this for the CN numbers on the pins you want, and then the interrupt will trigger for all selected pins.
The compiler has a function to see which bits have changed (input_change), to make working out what pins triggered easy.
Best Wishes |
|
|
|