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.

Bit access in keil C51

Status
Not open for further replies.

hithesh123

Full Member level 6
Joined
Nov 21, 2009
Messages
324
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
lax
Activity points
3,548
I am using C8051F120 MCU with Keil IDE.
The MCU has some bit addressable registers.

How do I store a variable in one of these registers? is it bdata?
How do I access the bits?

I tried unsigned int bdata mydata;

and then tried using mydata^x , where x is the bit field(0-7). But this doesn't work.
 

mathespbe

Full Member level 3
Joined
Jul 10, 2013
Messages
185
Helped
45
Reputation
90
Reaction score
44
Trophy points
28
Location
India, Tamilnadu, Coimbatore
Activity points
866
I am using C8051F120 MCU with Keil IDE.
The MCU has some bit addressable registers.

How do I store a variable in one of these registers? is it bdata?
How do I access the bits?

I tried unsigned int bdata mydata;

and then tried using mydata^x , where x is the bit field(0-7). But this doesn't work.

Bit accessible registers mean to those registers regards to uc unit... They are some SFRs. What you expect is a variable as a bit accessible. bdata is a data type which is used for bit addressable...
 
Last edited:

embpic

Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Activity points
5,213
if you want to access bit in keil use declaration as
for single bit access
Code:
bit variable_name;

for bit address space is use for variable of byte then
Code:
bdata unsigned char variable name;
 

Venkadesh_M

Advanced Member level 4
Joined
Jun 26, 2013
Messages
1,374
Helped
258
Reputation
516
Reaction score
254
Trophy points
83
Location
Coimbatore, India
Activity points
6,738
Hi look at this example

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
unsigned char bdata barray[3] = {0xAA, 0x55, 0xA5};
bit flag;
 
void main(void)
{
  unsigned char byte, mask;
 
  for (byte = 0; byte < 4; byte++)
  {
    for (mask = 0x01; mask != 0x00; mask <<= 1)
    {
      flag = barray[byte] & mask;
    }
  }
  while(1);
}



- - - Updated - - -

and you can use sbit to aces them, more on Bit Addressing...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top