CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Resume Next

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Resume Next
PostPosted: Fri Sep 09, 2005 6:33 pm     Reply with quote

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

View user's profile Send private message Send e-mail

RE:
PostPosted: Fri Sep 09, 2005 8:35 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 09, 2005 9:20 pm     Reply with quote

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







PostPosted: Sat Sep 10, 2005 6:16 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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