Help regarding 8051 C programming

Status
Not open for further replies.

Dhans

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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…