embedded systems developers tools, cross compilers
  Home  |   SwiftX Archive  |   SwiftForth Archive  |

Re: TASK HALT with another task

From: Elizabeth D. Rather <erather_at_forth.com>
Date: Sun, 10 Aug 2003 16:17:25 -0700

At 09:07 PM 8/10/2003 +0200, you wrote:

>Hi ,
>
> >> > > A task could execute the STOP instruction within itself to stop.
> >
> >Yes, that is how a task deactivates itself. However, once STOPped
> >it cannot start up again on its own; it needs to be started by another
> >task.
>
>
>I though this was only for a task with transitient behavior.

Well, yes, you asked how a task could stop itself. That's how.
If what you want is for the task to stop flashing until your other
button is pressed, you can do that with a single task, where if
the "stop" button is pressed you go into a loop executing
PAUSE (and not flashing) and waiting for the "start" button to be pressed
again whereupon you start flashing again. While flashing you'd need
to repeatedly check for the "stop" button to be pressed. The task
isn't ever actually STOPping, it's in one of two loops (e.g. BEGIN...UNTIL)
either flashing while checking for a "stop" button or not flashing while
checking for a "start" button.

> >>...
> >> > : READSWITCHES
> >> >
> >> > PIND C@ 254 =
> >> > IF TESTER HALT
> >> > ELSE PIND C@ 253 =
> >> > IF TESTER ACTIVATE
> >>
> >>You can't have an activate without anything following it. Where is your
> >>endless loop? I think you mean:
> >> > IF TESTER ACTIVATE SEQBITFLASH
> >>
> >> > THEN
> >> > THEN ;
> >
> >Noel is right, ACTIVATE needs to be followed by the code the
> >task is supposed to execute.
>
>The code as I wrote is with two tasks works and works well(see below).
>As soon as I add something after TESTER ACTIVATE
>in the REASSWITCHES word, then it doesn't work anymore.
>Why then does it work so good? I can't be by chance, can it?

The code is incorrect. See below. You may have multiple
bugs, where one is concealing another.

>It does exactly what I want, that is flashing stops
>when pressing switch 0 and restarts
>when pressing switch 1.
>I don't even have to keep the
>switch buttons pressed.
>The only thing I didn't succeed in doing is
>to start up the the tester task with the SEQBITFLASH
>without flashing.

That's because SEQBITFLASH flashes.

>Is there not a trick to do it working
>with the the code I have already? (see below).
>Replacing the IF-THEN structures by vectored
>execution is also error prone and though I
>tried it out, it doesn't work as well as this
>code with two tasks.

It will work if written properly.

>TARGET
>
>|U| |S| |R| BACKGROUND TESTER
>
>|U| |S| |R| BACKGROUND TESTER2
>
>: READSWITCHES
> PIND C@ 254 =
> IF TESTER HALT
> ELSE PIND C@ 253 =
> IF TESTER ACTIVATE

I promise you, if you ever execute this phrase your
task will crash, because it will fall through to the
semicolon at the end of the definition.

> THEN
> THEN ;
>
>
> : SEQBITFLASH ( -- )
> 1
> BEGIN
> PORTB C@ 2DUP SWAP - AND
> PORTB C! 100 MS 2*
> PORTB C@ 127 = IF DROP 1
> THEN
> 255 PORTB C! 100 MS
> AGAIN ; \ For in task
>
>
>
>
>
>: /TESTER ( -- )
> $FF DDRB C! \ Set PORTB as OUTPUT
> $FF PORTB C! \ set leds off at start up
> TESTER BUILD TESTER ACTIVATE
> BEGIN PAUSE
>
> SEQBITFLASH
>
> AGAIN ;
>
>: /TESTER2 ( -- )
> TESTER2 BUILD TESTER2 ACTIVATE
> BEGIN PAUSE READSWITCHES
>
> AGAIN ;

Sorry, I don't have time to debug this code in detail. I've tried to give
you some hints.

Cheers,
Elizabeth

==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Sun Aug 10 2003 - 16:17:57 PDT

This archive was generated by hypermail 2.2.0 : Mon Dec 01 2008 - 03:04:47 PST