Hi everyone,

First time positing and just wanted to compliment Matthias and the team on the 
good work on amforth.

Now onto my main issue...

I’ve recently run into amforth and have so far had a good experience with it 
and getting it to work with LEDs and some spi devices.

Recently, I thought I might try out multitasking but ran into some issues; 
“multi” hangs my system.

HW: I’m running it on an ATmega328 processor (in DIP format on a breadboard).

I have a simple program to initialize the PB1 pin (on which I have an LED) as 
an output and to toggle its voltage output level. This is known to work without 
multitasking.

The amforth-6.4/common/lib/multitask-test.frt file was the template from which 
I worked. The “multitask.frt” file has already been loaded.
Here’s the file I send to the microcontroller via amforth-upload.py:
******************************************************************************
testA1
marker testA1

: ms ( n -- ) 0 ?do pause 1ms loop ; \ call pause on wait
;

: init
        led0_gpio_init 
;

: run-demo
        begin
        led0_toggle
        #500 ms
        again
;

$20 $20 $10 task: task_demo

: start-demo
        task_demo tib>tcb activate
        \ words after this line are run in the new task
        run-demo
;

: starttasker
        task_demo task-init
        start-demo
        onlytask
        task_demo tib>tcb alsotask
        multi
;

: run-turnkey
        applturnkey
        init
        starttasker
;
******************************************************************************

System hanged in “starttasker”. Upon closer inspection I found the hang in 
“multi”.

A quick run of “ task_demo task-init start-demo onlytask task_demo tib>tcb 
alsotask ” at the prompt, 
followed by “tasks" gives the following which suggests the tasks are properly 
setup at 0x17B and 0x1AB.

******************************************************************************
 ok                                                                             
> amforth 6.4 ATmega328P                                                       
> hex                                                                           
 ok                                                                             
> tasks                                                                         
17B   unknown                                                                   
> task_demo task-init start-demo onlytask task_demo tib>tcb alsotask            
 ok                                                                             
> tasks                                                                         
17B   running                                                                   
1AB   running                                                                   
Multitasker is not running ok                                                   
> single                                                                        
 ok                                                                             
> tasks                                                                         
17B   running                                                                   
1AB   running                                                                   
Multitasker is not running ok                                                   
> 
******************************************************************************
If I execute "multi” at this point, the system just hangs and only recovers 
with a manual reset.

I find it interesting that “single” executes fine but “multi” hangs given that 
they look quite similar:

: single ( -- )
    ['] noop ['] pause defer!
;

: multi ( -- )
    ['] multitaskpause ['] pause defer!
;

It may hint that something may be amiss in “multitaskpause”. Mine looks like 
this:
: multitaskpause   ( -- ) rp@ sp@ sp ! follower @ dup @ i-cell+ >r ;

If you have any pointers on how to solve this, I’d be grateful if you’d share.

Regards,
Frank




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to