Problem with bit array


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

    Default Problem with bit array

    I don't seem to be able to get the bit array to work. I'm using PicBasic Pro Compiler 2.44 and the p16F648A

    I declare the var " flags var bit[8]" and it assembles ok but when I try and use it "flags[2] = 1" the bit does not get set. Am i doing something wrong or is there a problem with the bit array in this version.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Flags is the name of an internal PBP variable. Try changing the name to
    something else. It should work fine then.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    I just picked variable name flags when i wrote the post the variable name that I was using was "ChShmr1"
    Neighter "flag" or "flags" are listed as Reserved Words if they are they Reserved Words then shouldn't they be added to the list.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Actually there are several other variable names that should be included
    in the PBP reserved words list.

    For example;

    R0
    R1
    R2
    R2
    FLAGS
    GOP
    RM1, and more

    Look in the PBPPIC14.RAM or PBPPIC18.RAM files. Not sure why these
    aren't in the reserved words list..!

    Using R0, flags, etc with version 2.46 returns an error at compile time
    with "Redefinition of VAR".

    Not sure why you wouldn't get the same error with v2.44?

    With v2.46 this works;
    Code:
    X VAR BYTE       
    Y VAR BYTE
    BITS VAR BIT[8]
    
    Main:
        CLEAR
        FOR X = 0 to 7
         BITS[X] = 1
         Y.0[X] = BITS[X] ' Y.bit.X = BITS.bit.X
        NEXT X
        GOTO Main
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. DMX512 Problem ..Schema+Code
    By programmer07 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 21st March 2007, 15:39
  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