Bit set question


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2006
    Posts
    25

    Default Bit set question

    Hi,

    I want to set a particular bit of a word, so I am doing it this way:

    If channel < 16 then

    control1.(channel + 1) = 1

    endif

    I want to set the (channel + 1)th bit of control1 to 1. The complier does not like this. Do you know how else I can do this?

    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    control1.0(channel + 1) = 1

    or

    control1.1(channel) = 1
    <br>
    DT

  3. #3
    Join Date
    Oct 2006
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    Thanks....so just to confirm

    This command does change the (channel + 1)th bit right and not the 0th bit of control1?

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Yes. The (channel + 1) bit.

    By putting the .0 after the variable name, it forces PBP to use it as a BIT Array, regardless of what the original variable was defined as.

    If you use .0 then it starts at bit0
    If you use .5 it starts at bit5. An index value of 0 will set bit5. An index of 4 will set bit0 in the next byte.
    <br>
    DT

  5. #5
    Join Date
    Oct 2006
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    Thanks a lot!

Similar Threads

  1. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  2. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31
  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