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

latch interrupt on port B

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



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

latch interrupt on port B
PostPosted: Mon Jan 09, 2017 5:56 am     Reply with quote

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: 19513

View user's profile Send private message

PostPosted: Mon Jan 09, 2017 6:32 am     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jan 09, 2017 6:35 am     Reply with quote

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
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