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
change interrupt edge select port b2 18F87k22
Moderator: Benj
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
change interrupt edge select port b2 18F87k22
- Attachments
-
- int edge change.gif
- (56.91 KiB) Downloaded 1294 times
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: change interrupt edge select port b2 18F87k22
Hi Wolfgang,
This may not be the most elegant solution but it should work.
Another way would be to disable the interrupt in Flowcode and then re-enable using the alternate property setting.
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);
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
Re: change interrupt edge select port b2 18F87k22
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
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
- Attachments
-
- de and re activate.gif
- (67.57 KiB) Downloaded 1285 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: change interrupt edge select port b2 18F87k22
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
Re: change interrupt edge select port b2 18F87k22
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
""""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