Page 1 of 1
change interrupt edge select port b2 18F87k22
Posted: Thu Feb 23, 2012 12:19 pm
by saschech@gmx.de
Hello
If I call a secont time the int-macro to change the edge level, I become a warning,code not working....
A c-macro with:
intcon2 = intcon2 ^ 0x20; no correct work on my hardware
What is the correct way to change the level fron rising to falling to rising ...... edge inside my code?
xxxxxxxxxxxxxxxxxxxxxxxxxx
If i work with a "change int on port" (datasheet show RB4 to RB7 is port int) my code show reaction on change on port RB0 and RB1 ?!
Regards Wolfgang
Re: change interrupt edge select port b2 18F87k22
Posted: Fri Feb 24, 2012 1:13 pm
by saschech@gmx.de
Hello
Nobody can help?
Regards Wolfgang
Re: change interrupt edge select port b2 18F87k22
Posted: Fri Feb 24, 2012 1:46 pm
by Benj
Hi Wolfgang,
This may not be the most elegant solution but it should work.
Code: Select all
if (test_bit(intcon2, 5))
clear_bit(intcon2, 5);
else
set_bit(intcon2, 5);
Another way would be to disable the interrupt in Flowcode and then re-enable using the alternate property setting.
Re: change interrupt edge select port b2 18F87k22
Posted: Fri Feb 24, 2012 2:16 pm
by saschech@gmx.de
Hello Benj
I go these way also without success.
With your new code
the encoder work also only at all second stepp(I think the "int-flanke" not change) same as without these code.
anyway thank`s for help
Regards Wolfgang
Re: change interrupt edge select port b2 18F87k22
Posted: Fri Feb 24, 2012 3:13 pm
by Benj
Hi Wolfgang,
I've checked the FCD file for that device and the code seems to be correct for the INT2 interrupt so I'm surprised this isn't working.
Opt1_1="rising edge of RB2/INT2"
Opt1_1Val="st_bit(intcon2, INTEDG2);\n"
Opt1_2="falling edge of RB2/INT2"
Opt1_2Val="cr_bit(intcon2, INTEDG2);\n"
One thing I might suggest is that you don't actually have to disable the interrupt before re-enabling for the next transition.
The C code should use bit 4 instead of bit 5. Bit 5 is the interrupt edge for INT1.
Re: change interrupt edge select port b2 18F87k22
Posted: Fri Feb 24, 2012 3:33 pm
by saschech@gmx.de
Hello Benj
""""The C code should use bit 4 instead of bit 5. Bit 5 is the interrupt edge for INT1"""""
You are right , after i change my c-code from "" intcon2 = intcon2 ^ 0x20;"" to ""intcon2 = intcon2 ^ 0x10;""
now code work on hardware >> my mistake was , I count the bits incorrect........
Thanks again Wolfgang