How to access individual BITS

Status
Not open for further replies.

waqas_here

Junior Member level 2
Joined
Jan 20, 2008
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,463
Guyz plz help me out. I want to access individual bits while programming in C for AVR using AVR Studio. For example i want to check either individual bits in PINB is set or clear. I have been doing it using & operator e-g (PINB & 0x02). But i dun want to do it any more.
 

i am using keil for c in 8052. in this masking is used or keyword like sbit in manner as follows


sbit variable_name = pin # ;

this is to read form pins. to read , firs declare all pins as e.g

define num P0 ;
num = 0xFF;

for masking :

for example i want to reach bit 3 of port 1 then ;

define num P1;

unsinged int mask = 0x08 ; // temporary value

0000 1000 as i want to read bit 3 .

now i make a variable to store readed bit .

unsigned int get;

get = mask & num;
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…