> Just browing around the piclist.com site a little.. According to > http://www.sxlist.com/techref/microchip/multitasking.htm pre-emptive > multitasking on a p16 core is not likely possible. > > However, I think that it should be able to be done, because, if I were > to setup an interrupt to be every X cycles, and have a state variables > for each task, in the interrupt I would be able to save the state of > status and w, and goto to the next routine. Say the tasks are 1,2,3.. > step 0: Begin running routine 1 > step 1: Interrupt routine 1, goto routine 2, > step 2: Interrupt routine 2, goto routine 3, > step 3: Interrupt routine 3, goto routine 1, > step 4: Interrupt routine 1, return to routine 3, > step 5: Interrupt routine 3, return to routine 2, > step 6: Interrupt routine 2, return to routine 1, > step 7: repeat from step 1. > > Granted, this limits the call depth, but it should work nonetheless. > The routines would receive equal amounts of time per second, but not > the same position in time.. Like this: 123 132 123 132, they are out > of sequence, for lack of a better explanation. Nice idea, but it still has some problems: - when in step 1 you 'goto routine 2' in all but the first cycle, how do you know where in the code you must start? - how do you deal with routine 2 calling other routines and being interrupted when such a called routine was executing? If you go for the easy approach: each routine must run up to a fixed point (so you know it was not executing a subroutine, and you know where it was) you have reduced your multitasking to a set of finite-state machines, which can indeed be done on a 14-bit core. Google 'pic pumpkin'. Wouter van Ooijen -- ------------------------------------------- Van Ooijen Technische Informatica: www.voti.nl consultancy, development, PICmicro products docent Hogeschool van Utrecht: www.voti.nl/hvu -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist