[51] UART communication between 3 microcontroller

Status
Not open for further replies.

Azzy anxious

Junior Member level 2
Joined
Jan 28, 2014
Messages
23
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Visit site
Activity points
161
Hi guys,

Can anybody help me regarding uart communication with 3 microcontrollers.
One as a master and other two as a slave devices.

I m working on 89s52 micro-controllers, even i m able to communicate between one slave and master at a time bt when i m trying to communicate two slaves wd master,its not working.....

Code:
void uart_init()
{
	TMOD = 0x20;	// timer 1 8-bit auto-reload
	SCON = 0x50;	// Tx and Rx enable
	TL1 = 0xFD;		// Baud Rate 9600 8-n-1
	TH1 = 0xFD;		// Reload count
	TR1 = 1;		// Start timer
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Receiving 8-bit data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

unsigned char read()
{
	while(!RI);
	RI = 0;
	return(SBUF);
}

void uart_send(unsigned char value)
{
	SBUF = value;
	while(!TI);
	TI = 0;
}

i m using above codes for receiving data from both slaves......
Help me guys..........:sad:
 
Last edited by a moderator:

How is everything connected? What protocol are you using? What is your hardware? If you have the transmit port of both slaves connected to the same input, and they're both active, it's not going to work; you need to have some protocol for slaves to connect and disconnect from the bus.
 

I m using UART for one way communication..
The Tx pins of both slave controller is connected to the Rx of the master slave.....
I am sending some number according to high and low conditions of the pins of slave and receiving values on master nd checking them on lcd....
I am using same programming in both slave because both slave have same circuit....
and I have to check same thing for both.....the number send by both slave are differ......
 
As I said, if you have BOTH transmitters of the slaves tied together, and you don't disconnect one of them from the bus, it's not going to work. You can't have two outputs tied together like that.
 
If I enable one Tx (one of both slave) at a time thn
does it work or not.....?
I mean to say I enable the Tx pin only the time of sending data and after that immediately disable the Tx pin....
 

In case of 8051, not sending data is sufficient to disable the transmitter, because it's IO pins are opend drain with weak pull-up.
 

I work with PICs so what I might try may not be available in your micro. On PICs, at least the ones I use, there is a separate bit for enabling the UART transmitter and another for the receiver in one of the control registers. Since the TX line idles at a high state (that's why you can't tie them together), I would disable the UART transmitters on the slaves and set the pins to an inputs so they float. The Master would query the slave and when the slave was ready to respond, it would enable the transmitter, send the response, then disable the transmitter again. This should work if the slaves didn't have to initiate a request.

I haven't tried this scheme so I'm not sure if will work. I have designed circuits with multiple processors and I just picked a micro that had 2 UARTS to be the master. It made it much simpler but I also had the requirement that the slaves could query the master. 2 UARTS made it easy.

Another option is to add an open drain/collector buffer on the slave TX pin and wire-or them. With a weak pull-up on the master, the slave should be able to pull the TX line low when needed even if the other slave is holding it high.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…