Page 1 of 1

Disabeling interrupt

Posted: Wed Oct 05, 2011 2:45 pm
by Jan Lichtenbelt
Hi All,

I want to use the INT-interrupt on port RB0 of 16F887A. But I want both high-to-low and low-to-high interrups.
Is the next set up possible:
1) enable INT interrupt on high-to-low with macro HtL.
2) if interrupt occursin macro HtL I increase a counter, disable the interrupt and enable a new interrupt on low-to-high with macro LtH,
3) the same for this macro HtL, increse a counter, disable the interrupt and start HtL intterupt again.

Kind reagrds

Jan Lichtenbelt

Re: Disabeling interrupt

Posted: Wed Oct 05, 2011 2:53 pm
by Benj
Hi Jan,

Yes this is possible as we use this mechanism for one of the RC5 receive options.

You can keep the interrupt enabled and simply use the lines of C code below to switch the INT operation.

option_reg.INTEDG = 0; //Set the INT0 interrupt to trigger on falling edge

option_reg.INTEDG = 1; //Set the INT0 interrupt to trigger on rising edge

Re: Disabeling interrupt

Posted: Wed Oct 05, 2011 4:08 pm
by Jan Lichtenbelt
Dear Ben,

Some like this, with the Timer2 Interrupt_Counter?

if test_bit(option_reg,INTEDG)
{
clear_bit(option_reg,INTEDG); //Set the INT0 interrupt to trigger on falling edge
FCV_INTERRUPT_COUNTER=0;
}
else
{
set_bit(option_reg,INTEDG) ; //Set the INT0 interrupt to trigger on rising edge
FCV_TIME_ON= FCV_INTERRUPT_COUNTER;
}
Kind regards

Jan

Re: Disabeling interrupt

Posted: Wed Oct 05, 2011 6:44 pm
by Jan Lichtenbelt
The RB0/INT interrupt works both on rising and falling edge in one macro, see attachment.