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

INT_EXT firing off on startup, getc locking up

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



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

INT_EXT firing off on startup, getc locking up
PostPosted: Mon Sep 03, 2007 11:37 pm     Reply with quote

Hi,

I'm using INT_EXT to detect incoming data from another PIC. That other PIC does nothing for awhile, however, as soon as I enable the EXT_INT interrupt, the ISR fires off and locks up on the getc (because there isn't anything there to get).

I'm puzzled why it fires off.

I've tried an input call for PIN_B0 to make sure it is set as an input on init, I've tried changing ext_int_edge from H_to_L and L_to_H, all without results.

A workaround was to set the timeout to 1s in the #rs232 statement. However, I'd like to know why it's doing that.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 12:11 am     Reply with quote

Compiler version?
PIC type number?
Example code?

It is good practice to clear an interrupt before enabling it, do you do that?
Ttelmah
Guest







PostPosted: Tue Sep 04, 2007 2:14 am     Reply with quote

Ongoing to Ckielstrs's comment, not only is it 'good practice', but if you change the interrupt edge, it is _essential_.
The sequence should be:
Set the interrupt edge.
Clear the interrupt.
Enable the interrupt.

The normal way to code the interrupt handler, if using software RS232 (which your comment about 'getc' suggests), is as the first instruction in the handler, to use if(kbhit), to verify that there is data arriving (for the software RS232, this is 'true', if the input line is low, reflecting the start bit being present), to avoid problems from possible triggers by noise etc..

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