0
votes

I'm trying to create a UART Pass through for one of my project. But i could not figure out how i should tie the pins of microcontroller. I'm using embedded C & Keil for programming.

  1. I'm using NXP p89lpc954 Microcontroller(8051 based) for this purpose.
  2. My requirement is as shown below in the fig enter image description here

  3. I'm controlling a sensor through UART port. Under normal operation microcontroller program communicates with the sensor using UART-1 Port. But when i connect the micrcontroller UART-0 port to host computer, i want the host computer to directly communicate with the sensor by creating a pass through between UART-0 & UART-1.

Could any one suggest any idea how we can achieve this.

2
There's a lot of talent on Stack Overflow, but I think you will get better answers elsewhere. You might try Electrical Engineering Stack Exchange, and come back to Stack Overflow when you have programming and development questions. I don't know enough about the topic, but it seems kind of broad, and it may not be answerable on a quorum like the Stack Exchange network.jww
@jww : ... except that this is as software problem that Vinod thinks is a hardware problem.Clifford
It isn't clear why the computer can't be connected directly to the sensor. You can use hardware to solve who speaks with it. Why does the data have to pass through the microcontroller?Lundin

2 Answers

4
votes

It is not normally possible to directly and transparently connect one UART to another. You will have to provide appropriate software to transfer data from one UART to another.

If both UARTs run at the same baud rate this may be relatively simple - you can read the Rx register from one UART and write the value to the TX register of the other (and vice-versa for bi-directional comms). If you implement this using UART interrupt handlers, it can be more-or less transparent to other code running on the MCU. For this to work without buffering, you have to be certain you can transfer the data from one UART to the other before a hardware overrun can occur - your hardware may or may not have a FIFO, so hardware buffering may be as little as the Rx register and the input shift register (two bytes). If there are other software operations occurring that may interfere with this operation, you may still need buffering.

If the baud-rates differ, you will need to provide buffering at least to the slower of the two ports, and you will not be able to stream data from the fast port to the slow one - there must be pauses in the data stream to prevent buffer exhaustion.

On some devices it may be possible to reduce the software overhead significantly by using DMA transfers (unlikely on your part I imagine).

However you do it you will still need software to enable and configure the UARTs - there is no hardware-only or simple "pin-pin" pass-through solution.

0
votes

I would recommend looking to see if there is a UART pass through bit in a UART config register or a routing register. Other than that I would just use fly wires from the PC UART to the Sensor UART.