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 problem again

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



Joined: 03 Dec 2008
Posts: 45

View user's profile Send private message

#int_ext problem again
PostPosted: Thu Jul 22, 2010 9:38 am     Reply with quote

i use pic16f84a
I want to use int_ext as a triger and it can be repeated. but the thing is not what i imaged.

int1 ext_status=0;
#int_ext
void extisr()
{
if(!ext_status)
{
ext_status=1;
output_high(pin_a1);
}
else
{
ext_status=0;
output_low(pin_a1);
}
clear_interrupt(int_ext);

}

void main()
{
ext_int_edge(H_TO_L);
enable_interrupts(int_ext);
clear_interrupt(int_ext);

enable_interrupts(global);
while(1)
{

}
}

Actually this is a test program. what i am going to do is when i give the pin_b0 a H to L edge then it output different value from pin_a1 that means if there is continued interrupts then pin_a1 output should be like H L H L.....
But its act not what i planned other than weird. sometimes it no response when i give HTOL edge and sometimes it acts when i give LtoH edge.
Please help me find out what is the problem. Thanks in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Thu Jul 22, 2010 9:57 am     Reply with quote

How are you generating the edges?.
The commonest reason for the interrupt to trigger on what is seen as the 'wrong' edge, is bounce. You make a switch, thinking this just closes a contact, but in reality you get more than one make/break sequences, and the interrupt 'sees' the extra edge.
The other thing is whether you are sure the source is really crossing the required voltage thresholds. The INT input on the 16F84, is a Schmitt trigger input. Requires the voltage to go over 4v to 'see' a 'high' (if running on a 5v supply). Are you sure it is....
As a final couple of comments:
1) Use the code buttons - makes it much easier to read your code.
2) You don't have to clear the interrupt in the ISR. CCS does this for you (unless you specifically tell it not to...).

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