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

How can I use External interrupt

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



Joined: 15 Jan 2009
Posts: 8

View user's profile Send private message MSN Messenger

How can I use External interrupt
PostPosted: Wed Oct 07, 2009 7:17 am     Reply with quote

How can I use External interrupt ?

I have a function when my button RB0(INT0) to press that my LED can work.

That my code ...
Code:

#int_EXT
EXT_isr()
{
   output_low(pin_a2);     //LED
}

void main()
{
   ext_int_edge( H_TO_L );
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   for(;;)
  {
         printf("Test");
  }
}

Please help me to do this code thanks !!
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Oct 07, 2009 10:16 am     Reply with quote

You're doing that backwards.

You want the INT_EXT to monitor your button.
Toss out a flag to a main routine that say the button has been tripped and then with that flag, execute code that debounces the button and then checks for its valid states.

THEN, depending on that state, set your LED accordingly.

If that's all you're doing, it probably doesn't need to be interrupt driven.


-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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