How do I check (or set) a group of consecutive bits within a byte?


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,117


    Did you find this post helpful? Yes | No

    Default Re: How do I check (or set) a group of consecutive bits within a byte?

    From 2.4 page 36
    From 2.6 page 42

    or

    From 3.0 pages 70 an 78

    Ioannis

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: How do I check (or set) a group of consecutive bits within a byte?

    You're absolutely right!

    If it's any help to anyone else, when I searched for logical AND, the first instance that came up is on page 43. The proper names for the boolean operations (AND, OR, XOR) are not used on P42.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: How do I check (or set) a group of consecutive bits within a byte?

    Well, hopefully some good has come from my initial problem (which I've now sorted/worked around by other means)...thanks for your input everyone!

  4. #4
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: How do I check (or set) a group of consecutive bits within a byte?

    Hank, does PBP allow you to XOR a bit?

    Code:
    adcon0.2 = adcon0.2 XOR 1
    

    That's pretty much how I would do it BoostC ( adcon0.2 ^= 1 ).

    Cheerful regards, Mike

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,117


    Did you find this post helpful? Yes | No

    Default Re: How do I check (or set) a group of consecutive bits within a byte?

    This adcon0.2 = adcon0.2 XOR 1 does a logical XOR.

    You need bitwise XOR:

    adcon0.2 = adcon0.2 ^ 1

    Ioannis

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