PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
Moderator: Benj
PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
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?
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
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;
}
- Attachments
-
- RB0_INT test.fcf
- (6 KiB) Downloaded 289 times
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
Actually it will be like the following for your chip..
For INT0
For INT1
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;
}
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;
}
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
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.
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!!
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: PIC18F4685 RB0/INT0 & RB1/INT1 interrupt.
I am happy that it helps you and it pleases my heart. Thanks