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.

Help regarding 8051 C programming

Status
Not open for further replies.

Dhans

Junior Member level 3
Junior Member level 3
Joined
Sep 14, 2005
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,473
hi to all

I have developed one program that should send one bit at a time to 8051 port bit.
here i used "acc" as a intermediate register. i also used shifting opertaor and for loop. while i simulating this "Acc" value is getting changed for "for loop" and shifting operator.
here my code,
#include<reg51.h>
sbit plb0=P1^0;
sbit reglsb=ACC^0;
void main()
{
unsigned char data_value=0x44,x;
ACC=data_value;
for(x=0;x<8;x++)
{
plb0=reglsb;
ACC>>1;
}
}

can anyone debug this?????????????????
 

Dhans,

Don't use ACC, replace it with any variable like this, ACC is already used for other purpose


Code:
#include <reg51.h>

sbit plb0=P1^0;

void main(void)
{
unsigned char i,x;
   i = 0x44;
   for (x=0; x<8; x++)
       {
        p1bo = (i & 1 ? 1:0);
        i>>1;
       }    
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top