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

The correct code

From: Viviane.Beullens <Viviane.Beullens_at_swing.be>
Date: Mon, 11 Aug 2003 15:35:42 +0200

Hi,

Yes, Noel and Elizabeth, you were right.
The actions with ACTIVATE were not treated well in my code
and probably it worked only by chance. But it explained
probably why it didn't work with buttons - which is what I
will try to do in the next step.
 
Meanwhile FYI I give you the correct code as suggested by both of you.
The easiest solution actually was to factor out
the actions, so that

: SEQBITFLASH .. code ... ;

became
: SEQBITFLASH ACTIVATE BEGIN PAUSE ... code ... AGAIN ;

After this is done, this action can be assigned to a TASK, so:
TASK SEQBITFLASH
And this can then be done as often as needed.

The complete code is below. It works fine. When it'll be rewritten
with buttons I'll post it. Of course, all of your good advice
will still be welcome.

Thanks to both of you.
Viviane Beullens

TARGET

|U| |S| |R| BACKGROUND TESTER

|U| |S| |R| BACKGROUND TESTER2

: SEQBITFLASH ( -- ) ACTIVATE
      1
        BEGIN PAUSE
        
          PORTB C@ 2DUP SWAP - AND
          PORTB C! 100 MS 2*
          PORTB C@ 127 = IF DROP 1 CR
                          THEN
           255 PORTB C! 100 MS
         AGAIN ; \ To assign to TESTER

: READSWITCHES ACTIVATE BEGIN PAUSE
    PIND C@ 254 =
          IF TESTER HALT
              ELSE PIND C@ 253 =
                IF TESTER SEQBITFLASH
                THEN
          THEN AGAIN ; \ To assign to TESTER2

: /TESTER ( -- )
    $FF DDRB C! \ Set PORTB as OUTPUT
    $FF PORTB C! \ set leds off at start up
    TESTER BUILD TESTER
            SEQBITFLASH ;

: /TESTER2 ( -- )
   TESTER2 BUILD TESTER2 READSWITCHES ;
----------------------------------------------------------------------
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 Mon Aug 11 2003 - 06:40:07 PDT

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