Page 1 of 1

PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Tue Nov 06, 2012 2:54 pm
by Speedy2k
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?

Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Tue Nov 06, 2012 6:15 pm
by Enamul
The trick that Ben told and Jan used...
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;
}

Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Tue Nov 06, 2012 6:33 pm
by Speedy2k
Ok and what is the option.reg for the rb1/int1?

Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Tue Nov 06, 2012 7:04 pm
by Enamul
Actually it will be like the following for your chip..
For INT0

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;
}
For INT1

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;
}

Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Tue Nov 06, 2012 7:05 pm
by Enamul
Please let me know if you struggle in flowcode for that.. I will post but you can always try first.

Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Sat Nov 10, 2012 3:39 pm
by Speedy2k
Thanx a lot Enamul, you are the man! and thanx to everyone who help on this forum, this is pretty awesome!! I am always impresed by all the help avaible here! This is what make flowcode so awesome!!

Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.

Posted: Sat Nov 10, 2012 10:48 pm
by Enamul
I am happy that it helps you and it pleases my heart. Thanks