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
Interrupt jumping to specified location in main code
-
- 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
- Attachments
-
- INTERRTUPT.fcfx
- (19.3 KiB) Downloaded 435 times
-
- 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
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.
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
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?
Is there such a thing as a software microcontroller reset command in the pic?
-
- 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
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();
-
- 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
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)