change interrupt edge select port b2 18F87k22

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
saschech@gmx.de
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

Post 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
Attachments
int edge change.gif
(56.91 KiB) Downloaded 1294 times

saschech@gmx.de
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

Post by saschech@gmx.de »

Hello
Nobody can help?

Regards Wolfgang

User avatar
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

Post 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.

saschech@gmx.de
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

Post 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
Attachments
de and re activate.gif
(67.57 KiB) Downloaded 1285 times

User avatar
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

Post 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.

saschech@gmx.de
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

Post 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

Post Reply