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

Interrupt On change Feature for Port B "Clarification N

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



Joined: 16 Aug 2010
Posts: 95

View user's profile Send private message

Interrupt On change Feature for Port B "Clarification N
PostPosted: Mon Aug 23, 2010 8:00 pm     Reply with quote

Hello, I am using a PIC16F886 for a small project. I notice this part
supports Interrupt On change feature for all pins on Port B

I have a button connected to RB2 and would like to run this using one
of the interrupts. I am Unclear on how to designate RB2 for use as
a interrupt so hopefully someone can clarify.

in .h File for the part at the bottom, there are pin defines and a memory address for each of the IOC features.

#define INT_RB2

So it looks like the pin is defined for the compiler. Would something
like the following code snip be the correct method to use so that the compiler knows that I wish to generate a interrupt on RB2.

---------------------------------------------------------------------------

INT_EXT //<<<<Not sure if this is correct to use Smile
My ISR ()
}
Do something
{

Void Main(void)
{

disable_interrupts(GLOBAL);
enable_interrupts(INT_RB2);
ext_int_edge(H_TO_L);

}

Thanks Guys

Scott
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 8:13 pm     Reply with quote

The following thread has a demo program for #int_rb on the 16F886:
http://www.ccsinfo.com/forum/viewtopic.php?t=42384

The program expects push-button switches to be on pins B0, B1, and B2.
The external circuit for each pushbutton should be like this:
Code:

           +5v
            |
            <
            > 4.7K       
            <         ___ Push button switch 
To          |        _|_|_
PIC -----------------o   o------
pin                            |             
                              --- GND
                               -   
 
scottc



Joined: 16 Aug 2010
Posts: 95

View user's profile Send private message

PostPosted: Mon Aug 23, 2010 11:13 pm     Reply with quote

Thanks, PCM

That gives me something to work with

Scott
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