Page 1 of 1

Interrupt jumping to specified location in main code

Posted: Fri Oct 21, 2022 10:49 am
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

Re: Interrupt jumping to specified location in main code

Posted: Fri Oct 21, 2022 11:10 am
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.

Re: Interrupt jumping to specified location in main code

Posted: Fri Oct 21, 2022 11:55 am
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?

Re: Interrupt jumping to specified location in main code

Posted: Fri Oct 21, 2022 12:32 pm
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();

Re: Interrupt jumping to specified location in main code

Posted: Fri Oct 21, 2022 12:34 pm
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)

Re: Interrupt jumping to specified location in main code

Posted: Fri Oct 21, 2022 1:05 pm
by Maverick
Thanks for that. I don't need the state information.
If I add reset(); to the interrupt macro this should work

Re: Interrupt jumping to specified location in main code

Posted: Tue Oct 25, 2022 10:02 pm
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

Re: Interrupt jumping to specified location in main code

Posted: Mon Nov 14, 2022 12:23 am
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.