![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
evsource
Joined: 21 Nov 2006 Posts: 129
|
INT_EXT firing off on startup, getc locking up |
Posted: Mon Sep 03, 2007 11:37 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Sep 04, 2007 12:11 am |
|
|
Compiler version?
PIC type number?
Example code?
It is good practice to clear an interrupt before enabling it, do you do that? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Sep 04, 2007 2:14 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|