There is no multithreading on the Stamp in the formal sense. The newer stamps have RUN slots which permit multiple banks of code to be switched between. You could also implement a multithreaded-esque scheduler program which parcels out processor time to various subroutines, each scheduling tick, the scheduler makes a decision which code section is executed and calls the code. Since there are no interupts in pbasic, you cannot implement a preemptive scheduler, so each code section called has to play nicely and return control to the scheduler within a reasonable amount of time.
Jon has a very nice template program in PBasic which lets you cycle a 'state-machine' which selects among several 'tasks'. In effect, this lets you have a multi-tasking program. However, since the multi-tasking is NOT built into the PBasic run-time, it can be VERY slow, and it does NOT support interrupts.
If you added a nice external 50 mSec clock generator to it, you can even get predictable timing for your PBasic program.
Otherwise, PBasic is ONLY a single-threaded, non-interrupt-driven run-time which does 2000 PBasic instructions per second. You might be amazed at how useful this can be.
If multitheading or interrupts are required look at the SX chips with the SX/B compiler.
The SX does not support multithreading, but DOES support periodic interrupts.
The SX also supports pin change interrupts.
Or the SX is probably fast enough to use the 'state-machine' method also.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
Comments
If you added a nice external 50 mSec clock generator to it, you can even get predictable timing for your PBasic program.
Otherwise, PBasic is ONLY a single-threaded, non-interrupt-driven run-time which does 2000 PBasic instructions per second. You might be amazed at how useful this can be.
The SX does not support multithreading, but DOES support periodic interrupts.
The SX also supports pin change interrupts.
Or the SX is probably fast enough to use the 'state-machine' method also.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"Great people talk about great things, average people talk about average things, small people talk about other people."
·