|
|
View previous topic :: View next topic |
Author |
Message |
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
latch interrupt on port B |
Posted: Mon Jan 09, 2017 5:56 am |
|
|
I have 2 latching switches (not momentary) and I ORed them on RB0 Interrupt port to use the INT_EXT function. the problem is that when I press the first switch it is executed right, but the interrupt on RB0 remains active since it is latching. How I can deal with latching input interrupt? I do not wish to use the polling system.
I am using the PIC18F452 20MHz crystal. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Mon Jan 09, 2017 6:32 am |
|
|
This is a hardware problem....
Think about it. If the signals are latching, and or'ed, then the signal to the PIC is going to remain unchanged when a second one changes, since it is already on from the first signal...
Honestly, forget INT_EXT, and your or.
Just feed the two signals separately to two of the high bits of portB (B4 to B7). Then any change on these will trigger INT_RB. In your code read portB, then in the interrupt read the port, and compare the two bits to the bits you have stored. If either changes, have the code for this switch. The interrupt will trigger on each edge (making and breaking), but won't trigger unless there is a change. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Jan 09, 2017 6:35 am |
|
|
If I read your post correctly, you can't !
Latching switches work same as toggle switches (light switches), one position open, other closed. There's no way I know to 'see' the 2nd switch operate while the 1st is closed.
Even diode ORing them, same problem as long as one is 'activated', you'll not see the 2nd one.
If an ADC pin was free, you could feed different voltages to it...
The best, easy solution is to rearrange the PIC I/O to free up a 2nd PortB pin and have each switch have it's own input.... or... use a bigger PIC.
In any case, be sure to have GOOD HW debounce !
Jay |
|
|
|
|
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
|