|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Resume Next |
Posted: Fri Sep 09, 2005 6:33 pm |
|
|
I need a function like Visual Basic "Resume Next" where the program return to the function previous one interrupt. I have a button that shows a menu "Cancel / Continue", so if someone select "continue", the program must go on where it was.
I looked for in the LST file but I could not understand which and how many records were pushed on the stack.
Can you help me?
Thank you |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Fri Sep 09, 2005 8:35 pm |
|
|
Hi,
The interrupt service routine in a PIC does it for you automatically. The control returns to the state prior to the interrupt.
thanks
arunb |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Sep 09, 2005 9:20 pm |
|
|
No, I think what he is talking about is being in a function, an interrupt occurs and the return is to another function. Much like a task switch in an RTOS.
To the poster: Better describe what you are trying to do. Also, which PIC. |
|
|
Ttelmah Guest
|
|
Posted: Sat Sep 10, 2005 6:16 am |
|
|
The normal way to do this, is to run an external 'state machine', and simply change state with the button. So the main loop, has something like:
Code: |
while (true) {
switch (state)
case FIRST:
// For the various operating states
}
|
Then in the routine that handles the button, you just save the state, with something like:
Code: |
laststate=state;
switch (button) {
case RESUME:
state=laststate;
break;
case NEW:
state=NEWSTATEREQUIRED;
break;
}
|
I have this sort of approach running all the time on a variety of test instruments, with the 'state' being changed either from the internal keypad, or a serial command, and normally advancing on timers, when these events don't occur.
To keep things 'tidy' and do quite a bit of error prevention, the state variable is normally an enumeration, with the possible conditions of the instrument as the states.
'Resume next', is considered to be one of the most dangerous programming statements around, leading to a lot of problems, and as a design, should be avoided like the plague if possible.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|