serial communication between two 89c51
Discussion in "8051 Discussion Forum" started by yadavmahesh Aug 19, 2010.
Thu Aug 19 2010, 12:38 am
hi, please help me out with circuit to connect two 89c51, one transmitter nand other receiver. also 7 segment is connected to the receiver side.
i tried it once with the sample i found in this forum but it worked only in proteus not with real hardware.. reply fast plz
i tried it once with the sample i found in this forum but it worked only in proteus not with real hardware.. reply fast plz
Thu Aug 19 2010, 03:13 pm
Hi,
8051(1) RXD < ----------------------------- 8051(2) TXD
8051(1) TXD -----------------------------> 8051(2) RXD
Please make circuit as above with necessary components and Write Program using Serial Communications Interrupts in Both uC.
--
Gurpreet Singh
IMBUENT TECHNOLOGIES PVT.LTD.
(INDIA)
www.imbuent.com,www.embeddedcraft.org
" A person who never make mistakes,never try new things"
8051(1) RXD < ----------------------------- 8051(2) TXD
8051(1) TXD -----------------------------> 8051(2) RXD
Please make circuit as above with necessary components and Write Program using Serial Communications Interrupts in Both uC.
--
Gurpreet Singh
IMBUENT TECHNOLOGIES PVT.LTD.
(INDIA)
www.imbuent.com,www.embeddedcraft.org
" A person who never make mistakes,never try new things"
Fri Aug 20 2010, 12:08 am
can you post codes you tried. let me see if there is any problem with code.
Fri Aug 20 2010, 08:55 am
I am using BiPOM's Micro C:
http://www.bipom.com/products/us/202.html
to have 2 8051 boards ( MINI-MAX/51-C2 ) talk to each other through the serial port. There is a NULL modem cable in between so RXD goes to TXD and TXD goes to RXD.
On both sides, I initialize serial port to 9600 baud using the C function serinit(9600>>1);
I use C function putch() on one side to send bytes to the serial port. I use getch() on the other side to receive the bytes.
I have not tried but it should be fairly easy to add a 7-segment display board like this:
http://www.bipom.com/products/us/924.html
Cheers
Ken
http://www.bipom.com/products/us/202.html
to have 2 8051 boards ( MINI-MAX/51-C2 ) talk to each other through the serial port. There is a NULL modem cable in between so RXD goes to TXD and TXD goes to RXD.
On both sides, I initialize serial port to 9600 baud using the C function serinit(9600>>1);
I use C function putch() on one side to send bytes to the serial port. I use getch() on the other side to receive the bytes.
I have not tried but it should be fairly easy to add a 7-segment display board like this:
http://www.bipom.com/products/us/924.html
Cheers
Ken
Fri Aug 20 2010, 12:23 pm
i hope you are taking care of pin no.5 i.e. gnd
8051(1) RXD < ----------------------------- 8051(2) TXD
8051(1) TXD -----------------------------> 8051(2) RXD
8051(1) GND <----------------------------> 8051(2) GND
8051(1) RXD < ----------------------------- 8051(2) TXD
8051(1) TXD -----------------------------> 8051(2) RXD
8051(1) GND <----------------------------> 8051(2) GND
Fri Aug 20 2010, 04:42 pm
i have not grounded pin no. 5 of each, is it neccesary. my code for transmitter n receiver is below.
transmitter side
#include <REGX51.H>
void main()
{
int sig=0x55; // signal to be transmitted.
TMOD=0x20; // selecting Timer 1, with mode 8bit auto reload.
TH1=0xFA; // setting baud rate = 4800
SCON=0x50; // setting the 8bit Control reg which control the SBUF with RC5
TR1=1; // starting the timer
while(1) // thios point onwards the code is sending 0x55 all the time
{
SBUF=sig;
while(TI==0);
TI=0;
}
}
receiver side
#include <AT89X51.H>
#define d P2
void main()
{
char rxdata; // this variable recieves data
TMOD=0x20; // selecting Timer 1, with mode 8bit auto reload.
TH1=0xFA; // setting baud rate = 4800
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0); // this line will wait for the data to come
rxdata=SBUF; // as soon as the data is recieved its tranferred to a variable so that the next variable doesnt overwrite the data just receieved
RI=0; // clearing the flag.
if(rxdata==0x55)
d=0x24; // 0x24 displays 2 on the 7-seg
}}
transmitter side
#include <REGX51.H>
void main()
{
int sig=0x55; // signal to be transmitted.
TMOD=0x20; // selecting Timer 1, with mode 8bit auto reload.
TH1=0xFA; // setting baud rate = 4800
SCON=0x50; // setting the 8bit Control reg which control the SBUF with RC5
TR1=1; // starting the timer
while(1) // thios point onwards the code is sending 0x55 all the time
{
SBUF=sig;
while(TI==0);
TI=0;
}
}
receiver side
#include <AT89X51.H>
#define d P2
void main()
{
char rxdata; // this variable recieves data
TMOD=0x20; // selecting Timer 1, with mode 8bit auto reload.
TH1=0xFA; // setting baud rate = 4800
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0); // this line will wait for the data to come
rxdata=SBUF; // as soon as the data is recieved its tranferred to a variable so that the next variable doesnt overwrite the data just receieved
RI=0; // clearing the flag.
if(rxdata==0x55)
d=0x24; // 0x24 displays 2 on the 7-seg
}}
Fri Aug 20 2010, 04:48 pm
about circuit
7 segment is LT542. pin no 21 to 27 are connected to 7 pins of 7seg.. vcc is aplied to 3and 8 pin. pin 5 is left unused
8051(1) RXD < ----------------------------- 8051(2) TXD
8051(1) TXD -----------------------------> 8051(2) RXD....>7seg display(common anode)
plz help me for this ..
n thanx for replies
Sat Aug 21 2010, 12:59 am
you have to make changes in your circuit to free pins required for communication. try moving 7-seg display pin to other unused pin. or better if you can post your schematic here.
Sat Aug 21 2010, 11:36 am
Mon Aug 23 2010, 04:37 pm
your hardware probably not matching your software then..
coz how is this possible?
i dont see anything in circuit above.
coz how is this possible?
8051(1) TXD -----------------------------> 8051(2) RXD....>7seg display(common anode)
i dont see anything in circuit above.
Powered by e107 Forum System