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.

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.
 

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:

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;
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top