Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/24/04 08:46
Read: times


 
#81807 - AT89c51 serial communication problem
I want to make two AT89c51 mcus to communicate serially
one mcu will transmit whatever data is on its port 1 serially to another mcu that second mcu will show this data on its port 1.
I have written code but its not workingplz check the following code and tell me if there is any problem and if code is correct what may be other possibilites that i m not getting desired output on port 1 of receiving mcu:

//----- Transmit Prg
#inlcude <reg51.h>
void Serial_Init(void)
{
SCON=0x52;
EA=1;
ES=1;
TMOD=0x20;
TH1=0xE6;
TR1=1;
}

void Transmit_Char(unsigned char c)
{
SBUF=c;
while(!TI){} //Waits until transmit
TI=0;
}

void main(void)
{
unsigned char tchar;
P1=0x00;
P3=0x00;
tchar=P1;
Serial_Init();
Transmit_Char(tchar); // Here Sends port P1 to serial port
while(1){}
}
// End of Prog




/-------- Receive Prog
#inlcude <reg51.h>
void Serial_Init(void)
{
SCON=0x52;
EA=1;
ES=1;
TMOD=0x20;
TH1=0xE6;
TR1=1;
}

void call() interrupt 4
{
if(RI)
{
P1=SBUF;
RI=0;
}
}

void main(void)
{
Serial_Init();
while(1){}
}

// End of Prog

List of 14 messages in thread
TopicAuthorDate
AT89c51 serial communication problem            01/01/70 00:00      
   Try            01/01/70 00:00      
   While loop in Transmit Char function            01/01/70 00:00      
   mistakes            01/01/70 00:00      
      mistakes fixed but still in a fix            01/01/70 00:00      
         too more fix            01/01/70 00:00      
   Give little more details            01/01/70 00:00      
      more details            01/01/70 00:00      
   problem solved            01/01/70 00:00      
      answer wrong            01/01/70 00:00      
   Yet another problem you must fix.            01/01/70 00:00      
      Hex files needed            01/01/70 00:00      
      Check The serial port            01/01/70 00:00      
         Problem solved            01/01/70 00:00      

Back to Subject List