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 support@ccsinfo.com

Can I have more than one source generate a single interrupt?

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



Joined: 07 Nov 2008
Posts: 4

View user's profile Send private message

Can I have more than one source generate a single interrupt?
PostPosted: Fri Nov 07, 2008 2:39 am     Reply with quote

Hallo, I'm new at using interrupts (using the PIC18F4620) and wondering if I would be able to do the following Confused :

1) Have multiple sources generate a single interrupt such as an external interrupt?

2) Be able to determine which external source triggered the interrupt?

Or is it better to have a seperate interrupt lines for each external event and implement is as a port change interrupt? How would I then distinguish which pin(s) on the port caused the interrupt?

Thank you so much for the help!
MO
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Fri Nov 07, 2008 2:56 am     Reply with quote

You can do this quite easily.

The simple way is to connect each digital line to a standard IO line and then OR them together and connect this to an interrupt line. When an interrupt occurs you can read the IO lines to see which one generated the interrupt.

To reduce the number of IO ports used you can multiplex them to gether so 8 lines use only 4 IO pins plus the interrupt line. This only works if you can only have 1 interrupt at a time.

As you can see this requires more logic and a bit of digital electronics knowhow. Extra stuff may be required if you need to latch the IO inputs and you would need an int clr line.

Your best solution would be to use a port with interrupt on change. This does basically the same thing.
You connect your 4 lines to port B (4-7) and then if any of those pins change state an interrupt occurs, you can then read the port to find out which one. This is limited to whatever the pic offers, 4 IO pins in the case of my PIC.
MO



Joined: 07 Nov 2008
Posts: 4

View user's profile Send private message

PostPosted: Fri Nov 07, 2008 3:23 am     Reply with quote

Thank you Wayne for the quick reply! I did not consider reading the port value Embarassed . If I have enough IO pins avaibable I will use the port change interrupt. Thanks for explaining the options so clearly!

Regards,
MO
loginatnine



Joined: 07 Oct 2008
Posts: 8

View user's profile Send private message

PostPosted: Mon Nov 10, 2008 9:20 pm     Reply with quote

Wayne_ wrote:
You can do this quite easily.

The simple way is to connect each digital line to a standard IO line and then OR them together and connect this to an interrupt line. When an interrupt occurs you can read the IO lines to see which one generated the interrupt.

To reduce the number of IO ports used you can multiplex them to gether so 8 lines use only 4 IO pins plus the interrupt line. This only works if you can only have 1 interrupt at a time.

As you can see this requires more logic and a bit of digital electronics knowhow. Extra stuff may be required if you need to latch the IO inputs and you would need an int clr line.

Your best solution would be to use a port with interrupt on change. This does basically the same thing.
You connect your 4 lines to port B (4-7) and then if any of those pins change state an interrupt occurs, you can then read the port to find out which one. This is limited to whatever the pic offers, 4 IO pins in the case of my PIC.


With the interrupt on state change on B4-B7, is it possible to enable interrupt on only 2 or 3 pins? Like is it possible to use B6 and B7 as interrupts and B4 and B5 as normal IO?
THanks
Ttelmah
Guest







PostPosted: Tue Nov 11, 2008 3:20 am     Reply with quote

You can use them as outputs, but not as inputs, without the interrupt triggering.
Some chips do have individual 'bit' enables for this feature. However only a very few of the relatively recent ones.
A few of the very earliest PICs will trigger the interrupt, even if the pins are used as outputs. However you are unlikely to meet any now that do this....

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