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 CCS Technical Support

#INT_EXT
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah
Guest







PostPosted: Wed Sep 05, 2007 2:16 am     Reply with quote

You don't.
The interrupt will trigger on _both_ edges. All you do, is keep a copy of the port data, in a 'static' variable inside the routine, and then compare the current value, with the old, to see which bits have changed, and look at the current value to see which 'way' the level has changed.
So:
Code:

#INT_RA
void RA_changed(void) {
   static int8 old_port;
   int8 port;
   const RA4_mask=0b00010000;
   port=input_a(); //read the current port state
   //Now just check RA4
   if ((port^old_port)&RA4_mask) {
       //bit 4 _has_ changed
       if (port & RA4_mask) {
           //Here a rising edge has been seen

       }
       else {
           //Here a falling edge has been seen

       }
   }
   old_port=port;
}

If you want to check other bits, just mask for these as well.

Best Wishes
Kova



Joined: 06 May 2007
Posts: 35

View user's profile Send private message

PostPosted: Thu Sep 06, 2007 12:47 am     Reply with quote

Ttelmah wrote:
CUT


I have used:

Code:

..........
#int_ra
void ioc_isr(void)
{
delay_ms(10); //Debounce
if (input(PIN_A0)
........
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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