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.

Interfacing 89C2051 with an unknown controller

Status
Not open for further replies.

nakul8873

Newbie level 4
Joined
Apr 26, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
USA
Activity points
1,328
1. Using serial mode of Communication.
2. Unknown controller has a fixed protocol when I send a set of specified characters from 89C2051 to this controller it should respond by sending a fixed set of data and it is failing to do so.

3. I am using C language to program 89c2051 an I am sure the program works as I tested it using my laptop instead of unknown controller.

void init();
void command(char i);
void write(char i);
char Receive();

void main() {

char b[3];
TMOD = 0x20 ;
TH1 = 0xfd ;
TL1 = 0xfd ;
PCON |= 0x80 ;
SCON = 0x50 ;
TCON = 0x40 ;


while(1)
{
init();
SCON = 0x50 ;

SBUF = 0x4F;
SCON = 0x50 ;
Delay_ms(1);

SBUF = 0x57;
SCON = 0x50 ;
Delay_ms(1);

SBUF = 0x52;
SCON = 0x50 ;
Delay_ms(1);


SBUF = 0x11;
SCON = 0x50 ;
Delay_ms(1);

SBUF = 0x04;
SCON = 0x50 ;

Delay_ms(1);
SBUF = 0x15;

b[0] = Receive();
b[1] = Receive();
b[2] = Receive();

write(b[0]);
Delay_ms(500);

write(b[1]);
Delay_ms(500);

write(b[2]);
Delay_ms(500);
}
}

char Receive()
{
char r;
while((SCON & 0x01) == 0);
r = SBUF;
SCON = 0x50;
return(r);
}
void command(char i)
{
P1 = i;
P3.B5 = 0;
P3.B4 = 0;
P3.B3 = 1;
Delay_us(1);
P3.B3 = 0;
return;
}
void write(char i)
{
P1 = i;
P3.B5 = 0;
P3.B4 = 1;
P3.B3 = 1;
Delay_us(1);
P3.B3 = 0;
return;
}
void init()
{
P3.B3 = 0;
Delay_ms(15);
command(0x30);
Delay_ms(5);
command(0x30);
Delay_us(160);
command(0x30);
Delay_us(160);
command(0x38);
command(0x01);
command(0x10);
command(0x0C);
command(0x06);
return;
}

Thanks....
 

"3. I am using C language to program 89c2051 an I am sure the program works as I tested it using my laptop instead of unknown controller. "

Then you need to fix the unknown controller.
 

Hey thnks for responding but I got it working......
i think the problem was with programmer or compiler.....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top