PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
Posted: Tue Nov 06, 2012 2:54 pm
Is it possible to trigger the RB0/INT0 and RB1/INT1 interrupts on both rising edge and falling edge? Right now in flowcode i can only choose one or the other?
Old forums - please visit https://www.flowcode.co.uk/forums
https://www.flowcode.co.uk/mmforums/
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
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;
}
Code: Select all
if test_bit(intcon2,INTEDG0)
{
clear_bit(intcon2,INTEDG0); //Set the INT0 interrupt to trigger on falling edge
FCV_INTERRUPT_COUNTER=0;
}
else
{
set_bit(intcon2,INTEDG0) ; //Set the INT0 interrupt to trigger on rising edge
FCV_TIME_ON= FCV_INTERRUPT_COUNTER;
}
Code: Select all
if test_bit(intcon2,INTEDG1)
{
clear_bit(intcon2,INTEDG1); //Set the INT0 interrupt to trigger on falling edge
FCV_INTERRUPT_COUNTER=0;
}
else
{
set_bit(intcon2,INTEDG1) ; //Set the INT0 interrupt to trigger on rising edge
FCV_TIME_ON= FCV_INTERRUPT_COUNTER;
}