Though not a PIC application, I did a multitasking system in Borland Pascal several years ago. Each task had its own stack space. When a task finished something or went into a loop waiting for something else to happen, it called "NextTask." This pushed the current program counter on this task's stack, saved the current stack pointer value, advanced (or cleared if this was the last task) a "task pointer" which determined which stack to use. This task pointer then loaded the stack pointer with the appropriate value for this stack, then did a return. Each task's stack held variables local to that task and held return addresses, as mentioned above. When interrupts occurred, they just used the current stack, whichever one was active. I did a similar thing years earlier with a 6800 processor. The "separate stack" idea had not occurred to me yet. Also, due to limited memory space, it may not have worked anyway. Here, each task was a subroutine. Prior to exiting the subroutine (going on to the next task), the "continue address" was stored in RAM. When we got back to this task, we always called the first location in the subroutine. This location had an indirect jump (good old self modifying code!) to the appropriate location in the current task. Another, similar, approach (that could be used on the PIC) would be to have a byte hold a number representing the entry point where you want the task to continue. The top of our task subroutine would have a jump table the same as we use in a state machine. This multitasking approach is really just a state machine. Each time the task is called, it evaluates the state variable and picks up based on it. Prior to exiting the task's routine, we save an appropriate value in the state variable. Just some thoughts... Harold Harold Hallikainen harold@hallikainen.com Hallikainen & Friends, Inc. See the FCC Rules at http://hallikainen.com/FccRules and comments filed in LPFM proceeding at http://hallikainen.com/lpfm On Mon, 10 May 1999 16:36:35 +0200 Seyler Jean-Yves writes: > Hello all PICers, > > Some time ago, there has been a discussion about multitasking >and >solutions have been proposed with interrupts ... >Does any of you has an idea of a multitask kernel (2 tasks should >cover >most applications) without usong interrupt facilities in order to be >put >on a PIC 12C509 for example ? > >Thanks > ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com/getjuno.html or call Juno at (800) 654-JUNO [654-5866]