Interrupt jumping to specified location in main code

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Maverick
Posts: 69
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:58 am
Has thanked: 27 times
Been thanked: 8 times

Interrupt jumping to specified location in main code

Post by Maverick »

Hi
Attached is interrupt.fcfx to test interrupt usage
I have setup an interrupt on switch pins RA5, RA6, RA7 AND FAIL BUTTON RB6. The interrupt works fine
when the interrupt occurs; I need to jump to connection point A, not return to where the interrupt occurred.
Please advise on how this can be achieved
Attachments
INTERRTUPT.fcfx
(19.3 KiB) Downloaded 435 times

kersing
Valued Contributor
Posts: 192
Joined: Wed Dec 02, 2020 7:28 pm
Has thanked: 77 times
Been thanked: 64 times

Re: Interrupt jumping to specified location in main code

Post by kersing »

That can’t be done. You need to return from the interrupt to be able to process a next one. If you jump to the main loop your interrupt routine does not terminate and the next interrupt will not fire.

The usual way to handle this is to set a flag in the interrupt routine and in the main loop check if that flag is set. If there are other parts of the code that should not execute you could use a check to skip that code if the flag is set as well. Don’t forget to reset the flag in the main routine.

Maverick
Posts: 69
Joined: Wed Dec 02, 2020 10:58 am
Has thanked: 27 times
Been thanked: 8 times

Re: Interrupt jumping to specified location in main code

Post by Maverick »

I was hoping that wasn't the case as it means testing after every entry in main code or macros.
Is there such a thing as a software microcontroller reset command in the pic?

Steve-Matrix
Matrix Staff
Posts: 1472
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 204 times
Been thanked: 349 times

Re: Interrupt jumping to specified location in main code

Post by Steve-Matrix »

You should be able to use the following in a C code icon. It will not simulate, but should work on your hardware;

Code: Select all

RESET();

kersing
Valued Contributor
Posts: 192
Joined: Wed Dec 02, 2020 7:28 pm
Has thanked: 77 times
Been thanked: 64 times

Re: Interrupt jumping to specified location in main code

Post by kersing »

Yes, there is a reset instruction. That will result in the controller restarting the main code, state information will be lost so you will need a way to determine what caused the restart. Some controllers have a register that indicates the restart cause, you might want to check the data sheet for your target controller. (Sorry, no PC available so I can’t check your Flowcharts target)

Maverick
Posts: 69
Joined: Wed Dec 02, 2020 10:58 am
Has thanked: 27 times
Been thanked: 8 times

Re: Interrupt jumping to specified location in main code

Post by Maverick »

Thanks for that. I don't need the state information.
If I add reset(); to the interrupt macro this should work

WingNut
Posts: 265
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 36 times
Been thanked: 29 times

Re: Interrupt jumping to specified location in main code

Post by WingNut »

If you use an interrupt to activate the reset you can save any necessary settings (eeprom or mem card) before you initiate the reset

alanwms
Posts: 133
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: Interrupt jumping to specified location in main code

Post by alanwms »

Simply set a flag in the interrupt, Then when you are out of the interrupt, look at the flag, and reset it, then perform your macro.

Post Reply