Help with bit array


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    San Antonio, Texas
    Posts
    9

    Default Help with bit array

    I need help defining a word variable that I can access as a word, the high and low byte and as a bit array? I need to point to the a bit in the word with a for next loop. I know how to dfine a bit array. mybitarray var bit[16] but how do I access the word and the low and hi byte of the bit array. I know that you can access bits of a word like myWord.7 but how do I change the .7 in a for next loop?

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Dick M,All you need to do is setup an INDEX counter as I have done here. The counter can count from 0 to a maximum of 255 so to use this type of indexing your array of bits can not be any bigger than 255 which equals 32 BYTES or 16 WORDS. You then index into the array of BYTES or WORDS like so:

    INDEX VAR BYTE
    ARRAYBYTE VAR BYTE[2] 'USE BYTE ARRAY IF CONVIENIENT or
    ARRAYBYTE VAR WORD 'THIS WILL ALLOW 2 BYTES or 16 BITS OF DATA

    FOR INDEX = 0 TO 15 'INCREMENT THRU ALL 16 BITS
    ARRAYBYTE.0(INDEX) = 1 'GIVE BIT SOME VALUE
    NEXT 'INCREMENT INDEX

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Mar 2004
    Location
    San Antonio, Texas
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help Dave that was what I was looking for.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Doubt with interrupt on change
    By lugo.p in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th March 2010, 15:22
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. Problem with bit array
    By Dick M in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th May 2005, 17:03
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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