Page 1 of 1

Timer interrupts calling a macro

Posted: Mon Jul 03, 2017 2:29 pm
by TaliG
Hi,
I do not know if this is a bug, or im doing something wrong, or it cannot be done.
When I am enabling a timer interrupt and calling a macro, then disabling this interrupt all goes well. Then I would like to use the same timer for enother interrupt, re enabling the timer interrupt (same timer) calling enother macro, but the macro that is called is the one from the first interrupt.
Im working on the 18f47k40 and soon will move to the 67k40 (pins are never enough :) ).

Re: Timer interrupts calling a macro

Posted: Mon Jul 03, 2017 3:10 pm
by Benj
Hello,

An interrupt can only ever call one macro due to the way the code generation works. If you enable an interrupt calling macroA and then disable and re-enable this time calling macroB then this will not work as you expect.

One way to get around this is by using a global variable. Enable your interrupt calling macroA and inside macroA check the state of the variable using a decision icon. Then instead of re-enabling using a different macro you can change the value of the variable.

Hope this helps.

Re: Timer interrupts calling a macro

Posted: Mon Jul 03, 2017 4:00 pm
by TaliG
what i already do is using a swich inside the macro, is this correct? thank you for your help!

Re: Timer interrupts calling a macro

Posted: Mon Jul 03, 2017 5:44 pm
by Benj
what i already do is using a swich inside the macro, is this correct?
Yes that should work fine.