I have set an interrupt for change on portB.
This works just fine, triggers my macro any time a switch (3 of them on pins 1,2,3) on port B is changed.
What I need is for the program to go back to the start after the macro runs.
Right now it goes back to where it left off when the interrupt occurred.
Is there a way to cancel the interrupt at the end of the macro?
Bob
Jump to start from PORT INTERRUPT
Moderator: Benj
-
- Flowcode v5 User
- Posts: 211
- Joined: Tue Feb 19, 2013 9:51 pm
- Has thanked: 72 times
- Been thanked: 177 times
- Contact:
Re: Jump to start from PORT INTERRUPT
Not sure what you mean by "start". If you mean flash rom memory location zero then use reset(); in a c code icon box.
-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Jump to start from PORT INTERRUPT
Need the program to go back to the top and start again, NOT go back to where it was when the interrupt occurred.
I tried using a connection point but that did not work.
Simple program to light LEDS.
Switch (0) control 2 LEDS (same port) either on or off.
Switch (1) controls two LEDS (on 2 ports) and strobes them.
Switch (2) will over ride switch (1) and control those 2 LEDS plus an addition 2 ports flashing them in a wig wag fashion.
I just need to have the interrupt force the program back to the start to re-read the switches.
I posted what I have so far, still have to write the wig wag part.
Bob
I tried using a connection point but that did not work.
Simple program to light LEDS.
Switch (0) control 2 LEDS (same port) either on or off.
Switch (1) controls two LEDS (on 2 ports) and strobes them.
Switch (2) will over ride switch (1) and control those 2 LEDS plus an addition 2 ports flashing them in a wig wag fashion.
I just need to have the interrupt force the program back to the start to re-read the switches.
I posted what I have so far, still have to write the wig wag part.
Bob
- Attachments
-
- NavLights3.fcf
- (20.5 KiB) Downloaded 288 times
-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Jump to start from PORT INTERRUPT
Here fixed the missing routine.
Bob
Bob
- Attachments
-
- NavLights4.fcf
- (21.68 KiB) Downloaded 305 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Jump to start from PORT INTERRUPT
Hi Bob,
Also the interrupts are then disabled.
So if you don't exit at the very end of interrupt macro as intended, the stack will not get popped and interrupts will not be re-enabled.
The ways I can think around this is either
1) Set a flag within interrupt, and some jump to connection point after decisions blocks and /or loop until flag = 1 at the the end . Set flag = 0 at the place when connection point is declared.
2) Use a infinite loop within interrupt macro, and use the watchdog timer to reset program, since no clear watchdog commands are placed in interrupts.
Attached is using option 1. I can reduce the time connection A is reached after interrupt occurs if required.
Is there a maximum time connection A has to be accessed by?
Note: I have left the connection in, but not used it. May use it if necessary, but connection are not good programming practice.
Martin
I'm not a real expert on this but i believe if interrupt is accessed, the the stack is pushed with address to return to.Bobw wrote:Is there a way to cancel the interrupt at the end of the macro?
Also the interrupts are then disabled.
So if you don't exit at the very end of interrupt macro as intended, the stack will not get popped and interrupts will not be re-enabled.
The ways I can think around this is either
1) Set a flag within interrupt, and some jump to connection point after decisions blocks and /or loop until flag = 1 at the the end . Set flag = 0 at the place when connection point is declared.
2) Use a infinite loop within interrupt macro, and use the watchdog timer to reset program, since no clear watchdog commands are placed in interrupts.
Attached is using option 1. I can reduce the time connection A is reached after interrupt occurs if required.
Is there a maximum time connection A has to be accessed by?
Note: I have left the connection in, but not used it. May use it if necessary, but connection are not good programming practice.
Martin
- Attachments
-
- NavLights5.fcf
- (21.83 KiB) Downloaded 282 times
Martin
-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Jump to start from PORT INTERRUPT
Dah,
Why didn't I think of that.
Never thought about using the interrupt to set a flag. That works perfect, I even removed the unneeded jump point.
I am assuming, that the flag "interruptdetected" when set to =1, jumps out of the current loop and requires the program to start back at the beginning.
When running the simulator, program runs fine. When running in step mode, it is kind of shaky but works.
Thank you ever so much.
Bob
Why didn't I think of that.
Never thought about using the interrupt to set a flag. That works perfect, I even removed the unneeded jump point.
I am assuming, that the flag "interruptdetected" when set to =1, jumps out of the current loop and requires the program to start back at the beginning.
When running the simulator, program runs fine. When running in step mode, it is kind of shaky but works.
Thank you ever so much.
Bob
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Jump to start from PORT INTERRUPT
Hi Bob.
Your welcome. Just glad it working for you.
Thanks for letting us know.
Martin
Edit I have created an alternative method without use of interrupts.
If you would like only one switch allowed to be on at a time, then I can modify flowchart for you.
Your welcome. Just glad it working for you.
Thanks for letting us know.
Martin
Edit I have created an alternative method without use of interrupts.
If you would like only one switch allowed to be on at a time, then I can modify flowchart for you.
- Attachments
-
- NavLights6.fcf
- (23.98 KiB) Downloaded 307 times
Martin
-
- Posts: 157
- Joined: Sat Jan 22, 2011 10:39 pm
- Location: Michigan
- Has thanked: 6 times
- Been thanked: 27 times
- Contact:
Re: Jump to start from PORT INTERRUPT
For got to add.
No, there is now time limit for the program getting back to the start. If there is a 1 second delay or something will not matter in the real world.
Was even thinking of using ADC values for the delay times in the program so I can use trimmer pots on the actual circuit to control the delay times with out have to do it trial and error. Could almost use any PIC for this, I just had a few 16F1827 ones laying around.
Bob
No, there is now time limit for the program getting back to the start. If there is a 1 second delay or something will not matter in the real world.
Was even thinking of using ADC values for the delay times in the program so I can use trimmer pots on the actual circuit to control the delay times with out have to do it trial and error. Could almost use any PIC for this, I just had a few 16F1827 ones laying around.
Bob
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Jump to start from PORT INTERRUPT
No problem.
If you require anymore help, just let us know.
If you require anymore help, just let us know.
Martin