Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 231002

Forum Post: RE: The meaning of BIT1, BIT2, BIT3....etc.....

$
0
0
How should I interpret BIT1, BIT2...? They are shortcuts for accessing specific bits in a byte/word (BIT0 is just the first bit, BIT1 the second bit, and so on). They do not really have a meaning beyond that; they are just a shorter way or writing " (1 << x) ". The bits in most registers do have a meaning, so it would not make sense to use the BITx symbols for those. The bits in the GPIO registers, however, just affect the corresponding pins, whose meaning is determined by your custom hardware. So if you wanted to check the signal at pin P2.3, you would need to read the fourth bit. This could be written either as " if (P2IN & 8) " or as " if (P2IN & (1 << 3)) " or as " if (P2IN & BIT3) ".

Viewing all articles
Browse latest Browse all 231002

Latest Images

Trending Articles



Latest Images