Hello, did you ever try the multitasker, that is included with amforth? It did work, however, it did not survive switching power off and on again.
Matthias Trute and I have spent some effort to fix this and change the implementation accordingly. So please find the following new items: 1. a new version of trunk/lib/multitask.frt http://amforth.svn.sourceforge.net/svnroot/amforth/trunk/lib/multitask.frt this will be included in release/4.7 and later. Changes: - address of the task control block and stack sizes are now stored permanently in flash. - task-init will recreate the task control block in RAM from scratch. Typically this would be used in a "starttasker" or similar word (see below). 2. a piece of detailed documentation at http://amforth.sourceforge.net/recipes/single_multitasker.pdf This explains in considerable detail, how the multitasker works. It includes example code and a commented version of multitask.frt 3. Example code included below in this post. This will be added to the repository as well. Feel free to test and use this. Comments and questions are definitely welcome. We are aware that the implementation of the multitasker can be moved into the amforth core and changed in such a way that the programmer hardly notices it's there. However, we decided to release this and see, if anything else is needed. Thanks to Matthias and the nice folks on irc.belwue.de #forth-ev (german irc) for help in various ways. Cheers, Erich --- example code ----------------------------------------------------- \ run_multitask -- tested with amforth-4.7, atmega-32 $38 constant PORTB $37 constant DDRB include lib/multitask.frt \ load the multitasker : ms ( n -- ) 0 ?do pause 1ms loop ; \ call pause on wait variable N : init $ff PORTB c! \ portB: all pins high $ff DDRB c! \ all pins output 0 N ! ; : run-demo \ --- task 2 --- begin N @ invert PORTB c! 1 N +! &500 ms again ; $20 $20 0 task: task_demo \ create task, allot tcb + stack space : start-demo task_demo tcb>tid activate \ words after this line are run in new task run-demo ; : starttasker task_demo task-init \ create TCB in RAM start-demo \ activate tasks job onlytask \ make cmd loop task-1 task_demo tcb>tid alsotask \ start task-2 multi \ activate multitasking ; : run-turnkey applturnkey init starttasker ; ' run-turnkey is turnkey \ make run-turnkey start on power up ---------------------------------------------------------------------- ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel