Bitwise operations and masks: basics, help?


Results 1 to 12 of 12

Threaded View

  1. #3
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by mister_e View Post
    when you want to clear a bit you use AND, set a bit OR

    portc: x11111

    PORTC=PORTC | %00011111

    <hr>
    porta: xxxx10x,

    for this one you may also do it simple..
    TempVar=PORTA
    TempVar.1=0
    TempVar.2=1
    PORTA=TempVar

    OR, in some case, the following will work without much problem
    PORTA.1=0
    PORTA.2=1

    HTH
    Hello,

    Simple?
    Not so simple because each digit on the 7segments display needs (in my design) a pair of bytes for porta and portc that are found in a 10 entries array, and I prefer not to use intermediate variable.
    Sorry but I didn't understand your example above:

    portc: x11111
    PORTC=PORTC | %00011111
    porta: xxxx10x,



    let's say porta value is %00011001 and I need to alter only bits 1 and 2 with the following pattern stored in a BYTE varible called "avar":
    variable avar value is %-----10-

    ???

    Can I isolate a chunk of a byte and insert it at a desired position in anoter byte?
    Last edited by xnihilo; - 18th April 2008 at 15: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