CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Interrupt on change

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

Interrupt on change
PostPosted: Mon Jun 30, 2014 1:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 2:49 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 2:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 3:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 3:32 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 3:39 am     Reply with quote

ex_cni.c

Smile
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 3:47 am     Reply with quote

As always

Thanks so much!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19482

View user's profile Send private message

PostPosted: Mon Jun 30, 2014 4:55 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group