Shop OBEX P1 Docs P2 Docs Learn Events
Constant Array SX/B — Parallax Forums

Constant Array SX/B

VinchiVinchi Posts: 4
edited 2005-10-30 23:31 in General Discussion
Hello!

I dont know hove to make an constant array in SX/B? Something dont work. I am only strating with SX.

DEVICE          SX52, OSC4MHZ
', TURBO, STACKX, OPTIONX
FREQ            4_000_000

' =========================================================================
  PROGRAM Start
' =========================================================================

counter VAR byte
LED VAR RD

MASIVS VAR BYTE(8)
MASIVS(0) = %00000001
MASIVS(1) = %00000010
MASIVS(2) = %00000100
MASIVS(3) = %00001000
MASIVS(4) = %00010000
MASIVS(5) = %00100000
MASIVS(6) = %01000000
MASIVS(7) = %10000000
    

Start:
TRIS_A = %00000000
TRIS_B = %00000000
TRIS_C = %00000000
TRIS_D = %00000000
TRIS_E = %00000000

Main: 
FOR counter = 0 TO 7
  LED = MASIVS(counter)
  PAUSE 1
NEXT
GOTO START




Is it possible to make constant array like in C?

const char test[noparse]/noparse = {
11111111b,
11111110b,
11111110b,
00000000b,
00000000b,
11111110b,
11111110b,
11111111b,
00000000b};

Comments

  • BeanBean Posts: 8,129
    edited 2005-10-30 22:53
    I would do it as a LOOKUP table.

    LOOKUP counter,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,LED

    For larger tables use DATA and READ

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012
    Product web site: www.sxvm.com
    Available now... SX-Video OSD module $59.95 www.sxvm.com

    Life is NOT a box of chocolates.
    Life is a journey, and 99% of the time you get where your headed.

    ·
  • VinchiVinchi Posts: 4
    edited 2005-10-30 22:57
    THX! Good idea. But can you tel me what is wrong whit my script. Why i cant get the array variable to the port?
  • BeanBean Posts: 8,129
    edited 2005-10-30 23:31
    Vinchi,
    Since there are no constant arrays in SX/B, you must move your assignments inside the execute path.
    For example:

    DEVICE SX52, OSC4MHZ
    ', TURBO, STACKX, OPTIONX
    FREQ 4_000_000

    ' =========================================================================
    PROGRAM Start
    ' =========================================================================

    counter VAR byte
    LED VAR RD

    MASIVS VAR BYTE(8)

    Start:

    MASIVS(0) = %00000001
    MASIVS(1) = %00000010
    MASIVS(2) = %00000100
    MASIVS(3) = %00001000
    MASIVS(4) = %00010000
    MASIVS(5) = %00100000
    MASIVS(6) = %01000000
    MASIVS(7) = %10000000

    TRIS_A = %00000000
    TRIS_B = %00000000
    TRIS_C = %00000000
    TRIS_D = %00000000
    TRIS_E = %00000000

    Main:
    FOR counter = 0 TO 7
    LED = MASIVS(counter)
    PAUSE 1
    NEXT
    GOTO Main

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012
    Product web site: www.sxvm.com
    Available now... SX-Video OSD module $59.95 www.sxvm.com

    Life is NOT a box of chocolates.
    Life is a journey, and 99% of the time you get where your headed.

    ·
Sign In or Register to comment.