128 bit variable???


Results 1 to 5 of 5

Threaded View

  1. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 128 bit variable???

    Hi,
    The $55 is nothing in particular, just a number like any other number fitting into a byte, could have been 85 or 010101 (they are all the same thing by the way). It was just a number I took it doesn't mean or do anything in paricular in the example.

    There are many ways to put Var1-Var3 in the array. The most obvious would be to simply copy them:
    Code:
    myByteArray[0] = Var1
    myByteArray[1] = Var2
    myByteArray[2] = Var3
    Another, perhaps more elgant way is to create aliases pointing into the array
    Code:
    myByteArray VAR BYTE[3]
    Var1 VAR myByteArray[0]
    Var2 VAR myByteArray[1]
    Var3 VAR myByteArray[2]
    This way you can use FOR-NEXT loops etc to index the array AND access each entry just like any other byte. Remember that in this case there are only three bytes in RAM, Var1 is the same as myArray[0] - just another 'name' for it - for convinience. Like
    Code:
    myByteArray[0] = 128
    HSEROUT[#Var1, 13]
    The first line puts the value 128 in the first location of the array. The second line prints the content of Var1 which is the same thing as the first location of the array.

    If your databits are comming in on PortB.1 and, I assume you have some sort of clock or something on PortB.0, then something like:
    Code:
    Counter = 0
    While Counter < 128
      While PortB.0 = 0 : WEND 'Wait here for rising edge of clock.
      myBitArray[Counter] = PortB.1 'Get state of pin and store in array
      While PortB.0 = 1 : WEND ' Wait for clock to return low
      Counter = Counter + 1 ' Prepare for next bit
    WEND
    Something like that...

    /Henrik.
    Last edited by HenrikOlsson; - 28th October 2011 at 16:43.

Members who have read this thread : 0

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