Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

data exchange between 2 microcontrollers without UART usage

Status
Not open for further replies.

polarized

Member level 4
Joined
May 13, 2002
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Europe
Activity points
966
one wire between 2 mcu

Hello,


Does anyone of you have an idea how to exchange data between two 8051 based microcontrollers. But there is a catch, the UART-s of both of the microcontrollers are already occupied and can not be used for this purpose. The data packet lenght which they have to exchange is about 50 bytes. The speed is not so important and the direction of the data flow is always the same, from one microcontroller which sends the data to the other one which always receives the data. What would be the simplest hardware solution for doing this data exchange between two 8051 based MCU-s?

Regards.
 

dual port i2c

2pins - 1 for data, 1 for clock
and then bit banging on the receiver
you can also use a additionally pin for interrupt generation ...

... or ...

you connect clock signal to a port pin with int. capability ...

... or ... or ... or ...

This is not so hard, isn't it? :wink:
 

messaging uart packet microcontrollers

Hi,

May be you can consider memory sharing using dual port memory.

Another possible solution is to use I/O port pins for 4 bit data exchange and one bit for direction and negotiation between uCs.

Third solution is to use I2C bus for uC comunication. You can use software I2C routines for communication.

Regards
 

uart usage

Use the UART Tx line from the micro that always send data and a control line in order to redirect the data flow to the other microcontroller instead of RS232 chip (use a few gates for this). At the receiving microcontroler implement a software serial recieve UART routine. There are plenty of examples on the net for this routine.
Regards
 

I think the simplest solution would be to use the SPI port instead.
One CPU in Master mode and the other in Slave mode.
The speed can be very fast, but doesn't have to be.
It doesn't require any additional hardware.

You can also connect multiple MCU's at the SPI Bus, but the it gets more complicated:
**broken link removed**
 

Re: data exchange between 2 microcontrollers without UART us

HI you all ..
There is an app NOTE on the www.cygnal.com site on how implemente a soft UART for the 51 .. check it out .. you only need half of the code in each case .One for transmitting and another half for the receiver ..!
 

I have used I2C for this purpose. It is easy to implement if at least 1 controller has a hardware I2C port built in.

Another method that I have used is interrupt based transfer. The Sender interrupts the receiver controller and presents data on 1 or more pins. If the data is not faster than interrupt latency and process time, there is generally no need to do any handshake.
 

Re: data exchange between 2 microcontrollers without UART us

polarized said:
What would be the simplest hardware solution for doing this data exchange between two 8051 based MCU-s?

Simplest hardware solution is one wire from TX mcu to RX mcu. I am using one wire bus also for bidirectional connections. Protocol is simple enough - few clocks at start, then command byte, then data. Command byte defines how many data bytes will follow and what is direction of them. This solution is very good - I am using only one pin on every processor. You need to use pin with external inerrupt for input if you want to wakeup slave MCU from sleep mode by this bus also.

Also this one-wire bus is good for multi-processor connection. I was using this one-wire bus to connect up to 10 MCU (AT90S2313) in bidirectional mode, only one pin from every MCU. This last one was also designed to avoid a problem when any MCU in bus has not power supply. All traditional I2C and SPI will not work in this case.
 

Re: data exchange between 2 microcontrollers without UART us

to Klug:

Please upload the c code that you writed for one wire communication.

Does it create many overheads for micro and takes its time?

I think the best way is I2C,because it can operate in master and slave mode and you can have many slaves ,but it is better for micros that have hardware I2C .(not bit banging)
Bit banging takes many time and cpu clocks and in some application may be harmful.

I can not imagine how to use uart between more than 2 micros,I think it is suitable for communication between two micro.
 

Re: data exchange between 2 microcontrollers without UART us

7rots51 said:
to Klug:

Please upload the c code that you writed for one wire communication.

Does it create many overheads for micro and takes its time?

Ok, it is not taking time of micro, as it works only on timer interrupt. You need to set timer interrupt with overload frequency 2 times higher than bus takt frequency (This way you can read on middle of bus takt). Maybe this code takes some place of flash.

I am uploading only raw example - it was used on quickly written code, and is not so easy to understand, so excuse me for this pile of C strings. Also, I have deleted some parts from the code - deleted parts were not essential for bus operation, code will not compile without these parts, but it was working correctly.

There is no data exchange, only commands are sending to slaves from master, and master can ask state of slaves. Also, it has some very simple error checking. It is simply to add few additional commands to send and receive data by bus.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top