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
Posted: Thu Sep 06, 2007 12:47 am
Ttelmah wrote:
CUT
I have used:
Code:
..........
#int_ra
void ioc_isr(void)
{
delay_ms(10); //Debounce
if (input(PIN_A0)
........
All times are GMT - 6 Hours Goto page Previous1, 2
Page 2 of 2
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