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

Clearing B0 external interrupt ?

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



Joined: 26 Aug 2004
Posts: 23
Location: California

View user's profile Send private message

Clearing B0 external interrupt ?
PostPosted: Tue Jan 25, 2005 10:14 am     Reply with quote

I have a project with 2 hardware buttons, on the B0 & A5 inputs. I use the B0 interrupt to quickly grab a button press in most of the program.
In another situation I use the A5 button to call another procedure. In that one, I immediately disable the B0 interrupt. The user then uses the B0 button to return to the main loop. I watch for the B0 (return) button to be released, and even put in a 2 second delay to eliminate any contact bounce. Then I re-enable the B0 interrupt, and return to the main loop.
The problem is that the program immediately performs the B0 interrupt routine. I confirm this by having an LED-blink performed just inside the interrupt code. I acts as if the B0 button press is stored and then used when the B0 interrupt is enabled.
The 16F628 manual refers to the Intcon Register bit 1 as being the B0 Int flag, and notes that it must be cleared in software. I don't see anything in the CCS book that seems to do this. Any ideas on what I'm doing wrong? Is it that interrupt clearing. What command does this?
Regards,
Don
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 25, 2005 11:17 am     Reply with quote

You can manually clear the INTF bit before you enable interrupts.
That way, you will only get future interrupts, not one that has
already occurred. See the sample code in the last post of
this thread. Notice how INTF_BIT is cleared before interrupts
are enabled. INTF_BIT is declared with a #bit statement at the
top of the program.
http://www.ccsinfo.com/forum/viewtopic.php?t=17301
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