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

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



Joined: 10 Jun 2018
Posts: 1

View user's profile Send private message AIM Address

latch interrupt
PostPosted: Sun Jun 10, 2018 10:25 pm     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.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 11, 2018 12:03 am     Reply with quote

The most simple solution is to use INT_EXT for one switch and INT_EXT1
for the other switch.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 11, 2018 4:46 am     Reply with quote

One possible( probable) reason is the noise( bounce) made by the mechanical switches. Normally you'll need to add some R and C to the contacts to remove or dampen or quelch the EMI noise generated when the switch is actuated. Something as simple as a 1K pullup and a .1 across the switch may work though using an oscilloscope and seeing the waveform is really best. Should you decide to really 'play with PICS', save your money and buy a scope. Even a 30 yr old, 20MHz analog one will be a GREAT asset !
Jay
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Mon Jun 11, 2018 6:02 am     Reply with quote

You have 2 switches which each latch (not momentary). ORing them isn't going to work. You have to XOR them, which requires an external logic gate. If you can tolerate having them run to separate inputs, just do that. You already said that you don't want to poll them but honestly, why? Set up a timer to give you a 10ms 'tick' and use that to poll the switches. More than adequate to give a responsive feel.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon Jun 11, 2018 8:53 am     Reply with quote

As others have said. Think about it. Electrically what you have can't work. One switch made, the signal is pulled down (assuming they pull to ground). Operate the other switch, and nothing will happen. There is nothing for the processor to actually see...

There are lost of choices, and a lot depends on what you actually want to do.

First connect them separately to two pins supporting INT_RB. Then you can tell which switch has operated and which way it has changed.
Alternative, XOR. Problem here is that you'd again have to use INT_RB, otherwise you can only detect one edge of the change.
Alternative. Have separate pull-ups onh the two switches, and connect them via capacitors to the interrupt input. Have a larger pull up on this pin. Then when the switches go 'on' and the signal goes low, the capacitor will generate a pulse on the interrupt pin. Will allow you to detect both switches going on, but you won't know which one.
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