??? 01/03/05 11:40 Read: times |
#84257 - 8051 to 8051 communication |
Dear All,
I am doing a project on microcontroller to microcontroller communication using 89C51RD2 controllers'. The communication is done using RS-232 standard. The communication takes place at 57600 bps,8 data bits, 1 stop bit, no parity. The problem is that the communication between the PC and one controller at a time takes place properly. But when both the controllers are connected with each other the data transmission and reception are not proper. The code is pasted below. This code is for the transmitter controller: #include <reg51.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <Delay.h> #include <iodef1.h> // Definition of port lines #include <lcd4bit.h>//for LCD void Init_Serial( unsigned char PCON_VAL,unsigned char SCON_VAL, unsigned char TMOD_VAL,unsigned char TH1_VAL) { SCON = SCON_VAL; PCON = PCON_VAL; TMOD = TMOD_VAL; TH1 = TH1_VAL ; TR1 = 1; } void main (void) { char buffer[7]; char buffer1[6]; Init_Serial(0x00,0x52,0x20,0xFF); //@57600 for (;;) { printf("Hellon"); Delay_ms(100); // 100 ms delay gets(buffer,sizeof (buffer)); //buffer[6] Set_Line(2); // sets the 2nd line of display Display_Message(buffer); // Displays the received //buffer on the 2nd line of LCD Delay_ms(100); printf("Snehan"); Delay_ms(100); } The controller transmits "Hello " properly. This code is for the receiver controller: #include <reg51.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <Delay.h> #include <iodef1.h> #include <lcd4bit.h> void Init_Serial( unsigned char PCON_VAL,unsigned char SCON_VAL, unsigned char TMOD_VAL,unsigned char TH1_VAL) { SCON = SCON_VAL; PCON = PCON_VAL; TMOD = TMOD_VAL; TH1 = TH1_VAL ; TR1 = 1; } void main (void) { char buffer[7]; char buffer1[6]; Init_Serial(0x00,0x52,0x20,0xFF); //@57600 for (;;) { gets(buffer,sizeof (buffer)); Set_Line(2); Display_Message(buffer); Delay_ms(100); printf("Hi!!!n"); Delay_ms(100); gets(buffer1,sizeof (buffer1)); //buffer[6] Set_Line(2); Display_Message(buffer1); Delay_ms(100); } In response to the first controller's 'Hello' the second controller sends "Hi!!!". The first controller receives it as " !Hi!! ". In response to " Hi!!! " the second controller receives the string as "aSneh". This continues until power-off. I don't understand what the problem is. I have wasted my 3 days on it. Please tell me reason for the same. |
Topic | Author | Date |
8051 to 8051 communication | 01/01/70 00:00 | |
Try at a lower baud rate | 01/01/70 00:00 | |
Re: | 01/01/70 00:00 | |
8051 to 8051 communication | 01/01/70 00:00 | |
Which C Compiler? | 01/01/70 00:00 | |
Possible Solution | 01/01/70 00:00 | |
same kind of problem | 01/01/70 00:00 | |
Re:' ' | 01/01/70 00:00 | |
SMS? | 01/01/70 00:00 | |
Buffers too small? | 01/01/70 00:00 | |
Inter Character Spacing??![]() | 01/01/70 00:00 |