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 support@ccsinfo.com

my interrupt code and question

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







my interrupt code and question
PostPosted: Tue Aug 03, 2004 10:48 am     Reply with quote

I want to put an interrupt on a single pin, the example that comes with CCS does it on an entire RB port with #int_rb.

How do I put an interrupt just on say PIN_RB3?

here is the code I have so far


Code:


#include <16F876.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)


#int_rb
void detect_rb_change()
{
printf("wake up");
}


void main() {

   enable_interrupts(INT_RB3);
   enable_interrupts(GLOBAL);

   output_low(PIN_B0);
   while (TRUE) {
   
   sleep();

   }
}



What I'm trying to do is sleep until pin rb3 is set to +5 then say 'wake' and finally go back to sleep again. very simple right? its doable I hope.

Nick
Guest








PostPosted: Tue Aug 03, 2004 10:55 am     Reply with quote

PICs aren't Zilog processors. They have limited interrupt capabilities.
You didn't tell what PIC you use. Check out the manual to find out your possibilities (e.g. 16F series have only 1 Ext IT 18F452 (RB0) has 2 (RB0 and RB1) 18F6720 has 4 (pin_b0-3) etc.)
Nick
Guest







PostPosted: Tue Aug 03, 2004 1:36 pm     Reply with quote

I c, I looked at the datasheet and it shows RB0/INT I assume that is an interput.


#int_rb does that point to pin rb0?

Many Thanks!
Nick
Guest







PostPosted: Tue Aug 03, 2004 1:40 pm     Reply with quote

I did a google search and it pulled up '#INT_EXT'

Thanks!
Nick
Guest







PostPosted: Tue Aug 03, 2004 1:49 pm     Reply with quote

btw here is the link good site.
http://www.fernando-heitor.de/pic/ccs-compiler/praeprozessor.htm
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Aug 03, 2004 2:09 pm     Reply with quote

For the 16F876 you have three interrupts available for your use. RB0/INT, which is PortB bit 0 (pin 21 on a DIP package), Timer0 and Input Change on PortB bits 7 - 4. This is what is generated when using the Project Wizard if you want to use RB0 as the interrupt:

Quote:

Inserted into .c file before main():

#int_EXT
EXT_isr()
{

}


Inserted into .c file in main():

enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);


The '#int_RB' is used on the PortB 4 - 7 'interrupt on change' interrupt.

Ronald
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