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....