13

I want to make a communication between my PIC18F4550 and my PC but I'm getting stuck whether I should use UART or USART for long distance. When it's more advantageous to use the one instead of the other one?

Tata Simano
  • 131
  • 1
  • 5

4 Answers4

12

For your purposes, the UART and USART are the same thing. UART stands for universal asynchronous receiver/transmitter. The additional S in USART stands for synchronous. It's just a little added capability Microchip gave the module to make it more useful in some cases. That extra capability doesn't apply in your case.

The PC COM port only takes a UART to talk to. The fact that the USART could have been used in a different way is irrelevant to you, except that maybe you have some additional configuration bits that have to be set the right way.

Olin Lathrop
  • 313,258
  • 36
  • 434
  • 925
5

Short Answer: Use whichever you chip has

To fully examine the question, it's necessary to decode the acronyms:

A Universal Asynchronous Receiver Transmitter is your traditional "serial port". It is asynchronous in the sense that only a single signal is involved - no clock is transmitted, and instead the receiver must recover a clock, typically by oversampling.

In contrast a Universal Synchronous Asynchronous Receiver Transmitter is a more versatile device with UART-style asynchronous modes, but which can also optionally be configured to operate in synchronous modes where a clock is sent along with the data. Depending on capability, this might include interoperation with well-known synchronous serial formats, for example SPI or I2S.

A few MCUs may offer both types of peripherals. For a basic asynchronous serial need you could choose either. However your choice might be influenced by the pins on which a given peripheral can operate, other needs in the system, etc. A factory ROM bootloader might only operate on some peripherals and not others. There may also be differences in buffer support, word lengths, parity support, associated control signals, etc. And the software interface may be completely different between the two.

Chris Stratton
  • 33,491
  • 3
  • 44
  • 90
4

They are basically the same thing for your microcontroller.

USART stands for universal asynchronous and synchronous receiver/transmitter. UART stands for universal asynchronous receiver/transmitter.

Asynchronous data transmission would most of the time be used in this communication protocol. The Synchronous data transmission is rarely used because you have much better synchronous communication protocol such as SPI & I2C.

Thinh Le
  • 141
  • 3
  • 2
    "The Synchronous data transmission is rarely used because you have much better synchronous communication protocol such as SPI & I2C." Beware, it seems you are comparing apples and oranges :-) SPI & I2C are typically used for relatively short distances. The Synchronous mode of a USART is typically used for longer-distance interfaces e.g. multiple feet or more. I have worked with many synchronous communication interfaces e.g. V.35 or even the optional synchronous signals on V.24, to connect to synchronous modems. They all required a USART and could not be sensibly replaced by SPI & I2C. – SamGibson May 19 '19 at 17:25
  • Thank you so much for the information. – Thinh Le May 20 '19 at 14:57
3

Your microcontroller (MCU) has a Universal Synchronous/Asynchronous Receiver/Transmitter (USART) in it. This functional unit supports a synchronous communication mode and an asynchronous communication mode.

In synchronous mode, transmitter Tx is connected to receiver Rx by a CLOCK wire and a DATA wire. Once per CLOCK period, Tx sends another bit on DATA and Rx takes another bit from DATA. The transfer timing is governed by CLOCK and therefore known to both Tx and Rx. So both Tx and Rx can use higher bit rates than in asynchronous mode.

However, two wires/connector pins are needed instead of one and excessive skew or jitter between CLOCK and DATA leads to corrupted data being received. The timing within line drivers and line receivers carrying CLOCK and DATA must be closely matched to reduce this skew. Both the interface and the two-wire factors become more prominent over longer distances, with long cables and/or multiple connection hops.

In asynchronous mode, transmitter Tx is connected to receiver Rx by a DATA wire. Once per timed bit period, Tx sends another bit on DATA and Rx takes another bit from DATA. The transfer timing is governed by the frequency separate oscillators in Tx and Rx, each of which is unknown to the other and will be slightly different. Therefore the maximum reliable bit rate is lower than for synchronous mode.

At the start of every new byte, Rx uses the starting STOP-START bit transition to resynchronise to the incoming bit sequence timing. This makes the delays from line drivers/receivers, cables and connectors irrelevant to the bit period timing, though not to the bit quality. Only one wire is needed per communication signal instead of two, reducing the cost in cables, connectors and line drivers/receivers.

So it depends upon your acceptable costs, the distances you are travelling and the capabilities of Tx and Rx. Your PC is likely to only support asynchronous mode on a standard COM port, requiring a special port (PCIe or USB, likely USB) for synchronous mode.

TonyM
  • 22,898
  • 4
  • 39
  • 64