View previous topic :: View next topic |
Author |
Message |
MO
Joined: 07 Nov 2008 Posts: 4
|
Can I have more than one source generate a single interrupt? |
Posted: Fri Nov 07, 2008 2:39 am |
|
|
Hallo, I'm new at using interrupts (using the PIC18F4620) and wondering if I would be able to do the following :
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
|
|
Posted: Fri Nov 07, 2008 2:56 am |
|
|
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
|
|
Posted: Fri Nov 07, 2008 3:23 am |
|
|
Thank you Wayne for the quick reply! I did not consider reading the port value . 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
|
|
Posted: Mon Nov 10, 2008 9:20 pm |
|
|
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
|
|
Posted: Tue Nov 11, 2008 3:20 am |
|
|
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 |
|
|
|