Accessing bytes within a word array


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default Accessing bytes within a word array

    I have two tables each containing 11 entries of OnTime values ranging from 10 to 1023 mSecs in the master PIC18F4620. These will form a LookDown table in a separate PIC 16F88 once I can figure out how to send the values via a 9600 8,N,1 link.

    I need to send these via SEROUT2. SEROUT2 only sends BYTES so I need to break the OT0[x] word values into .BYTE0 and .BYTE1 halves before sending.

    A VAR BYTE
    B VAR BYTE
    C VAR BYTE
    OT0 VAR WORD[10] 'Tank 0 Solenoid valve OnTime values at different pressures
    OT1 VAR WORD[10] 'Tank 1 Solenoid valve OnTime values at different pressures
    DataIO var portc.0 'Bi-directional pressure data to 16F88

    This does not work...
    serout2 dataio, 84, [ ot0[0].byte0, ot0[0].byte1,_
    ot0[1].byte0, ot0[1].byte1, ot0[2].byte0, ot0[2].byte1, _
    ot0[3].byte0, ot0[3].byte1, ot0[4].byte0, ot0[4].byte1, _
    ot0[5].byte0, ot0[5].byte1, ot0[6].byte0, ot0[6].byte1, _
    ot0[7].byte0, ot0[7].byte1, ot0[8].byte0, ot0[8].byte1, _
    ot0[9].byte0, ot0[9].byte1, ot0[10].byte0, ot0[10].byte1]

    This also does not work ......
    for a = 0 to 10
    b = OT0[a].byte0
    c = OT0[a].byte1
    SEROUT2 DataIO, 84, [b, c]
    next a

    I keep getting 'This style array syntax not supported' I have tried several ways and read the new PBP3 manual pages 272 to 276 but I still can't crack it.

    Any help greatly appreciated.

    Thanks
    BrianT

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Accessing bytes within a word array

    Hi Brian,
    Try:
    ot0.LowByte[0], ot0.LowByte[1] 'first WORD
    ot0.LowByte[2], ot0.LowByte[3] ' second WORD.

    See Melanies excellent post on the subject for further details.

    /Henrik.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Accessing bytes within a word array

    Ripper - it now compiles!!

    Thanks Henrik.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Accessing bytes within a word array

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts