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

Simple External Interrupt Handler

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







Simple External Interrupt Handler
PostPosted: Sat Oct 13, 2007 3:28 pm     Reply with quote

I need to be able to run an ISR each time a line on a particular port changes. Sounds simple enough but I keep getting preprocessor errors when using any other port but B.

What am I missing? Below complies fine but doesn't seem to turn the

--
#include <16F877A.h>

#FUSES NOWDT
#FUSES HS
#FUSES NOPUT
#FUSES NOPROTECT

#use delay(clock=20000000)

#include <stdlib.h>


#INT_RB
void alarm_ISR(void)
{
int8 tpb;

tpb = input_b();

if (tpb & 0x01)
{
output_high(PIN_A5);
}
else output_low(PIN_A5);
}

void main(void)
{
set_tris_b(0b00000111);

enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 13, 2007 3:45 pm     Reply with quote

Before you do anything else, add the NOLVP fuse. Without that fuse,
the PIC will lock-up if pin RB3 goes high.

Also, when you post code, enable the tickbox below the posting window
to disable HTML. Then you won't get lines like this:
Quote:
#include
Ttelmah
Guest







PostPosted: Sat Oct 13, 2007 4:21 pm     Reply with quote

Read the data sheet.
What pins does the RB interrupt respond to?.
Does this include bit 0 of the port, which you are testing?.....
Also, remember the need to have something to stop the main running off the end, and sending the processor to sleep.

Best Wishes
Will
Guest







PostPosted: Sat Oct 13, 2007 4:52 pm     Reply with quote

I'll check again, but I was sure it responded to A5-A7 on port A, all of B.

The code above doesn't seem to respond either and I forgot my serial cable back on campus...
Ttelmah
Guest







PostPosted: Sun Oct 14, 2007 2:22 am     Reply with quote

No, it responds to B4 to B7 _only_, you are testing B0....
Sction 12.10.3 in the data sheet.
On some chips, it responds to other bits, but not on the 877

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