Shop OBEX P1 Docs P2 Docs Learn Events
SX/B Question — Parallax Forums

SX/B Question

ClintClint Posts: 95
edited 2007-02-12 22:24 in General Discussion
I am looking at the·Quadrature Encoder example shown in the·SX/B Help and I have a question about how a variable is defined in this code.

···EncPort········ VAR···· RA····················· ' encoder port
·· encNew = EncPort & %00000011···········' get econder bits

What does the & %00000011 do?

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-02-12 22:20
    Clint,

    & %00000011 performs a logical AND operation using the bit pattern that follows the percent sign. In the code section referenced this operation leaves encNew with the value of the first two bits of EncPort (RA). The six higher bits of EncPort are not included in the value of encNew since those bits are AND’ed with zeros.

    I hope this helps.

    - Sparks
  • ClintClint Posts: 95
    edited 2007-02-12 22:24
    I gotcha, thanks!
Sign In or Register to comment.