Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top