Elektroda.com
Elektroda.com
X

Search our partners

Find the latest content on electronic components. Datasheets.com
Elektroda.com

USART vs. UART - what are the differences?

ghost666 8628 15
This content has been translated flag-pl » flag-en View the original version here.
  • Have you ever used the term UART only to be corrected by another engineer that it is not a UART but a USART? In some cases the two terms are interchangeable, but in many others it is incorrect to use them interchangeably. Let's take a look at what exactly USART and UART are, and what are the main differences between them.

    Most embedded engineers are familiar with the UART interface: universal asynchronous receiver / transmitter. It is a microcontroller peripheral that converts incoming and outgoing data bytes to a serial stream. A start bit starts a serial stream and a stop bit or two ends a data word (frame). The UART also has the ability to add a parity bit to the frame to help detect if an error has occurred during transmission. Picture 1 shows a standard example of a frame that can be seen by viewing data transmitted over the UART.


    USART vs. UART - what are the differences?
    Fig. 1. Data frame in the UART interface.


    USART, on the other hand, is a universal synchronous / asynchronous receiver / transmitter. It is a microcontroller peripheral that converts incoming and outgoing data bytes into a serial bitstream ... The definition of USART is identical to the definition of UART, but in short there is an additional word - "synchronous". So there must be some differences, otherwise USART would be the same as UART and no one would have to correct anyone.

    Indeed, the differences are, and it is important. Let's look at them one by one.



    The first difference between USART and UART is how serial data can be clocked. The UART generates its own data clock internally in the microcontroller and synchronizes it with the data stream detecting the initial transition - the start bit. There is no incoming data related clock signal here, so in order to properly receive a data stream the receiver needs to know in advance what the baud rate should be.

    On the other hand, USART can be configured to work in synchronous mode. In this mode, the peripheral device sends the clock signal to the outside, and the receiving peripheral device can retrieve it from the data stream without knowing the data rate in advance. Alternatively, some links may even use a separate clock line to clock the entire transmission. The use of an external clock allows for a much higher data transmission speed using the USART interface than the standard UART - this type of transmission reaches speeds of up to 4 Mbps.

    The second important difference between USART and UART interfaces is the number of protocols supported by a peripheral device. UART is simple and offers only a few options for the basic data format. You can configure the number of stop bits and the occurrence and method of computing the parity bit of the frame. USART is much more complex and can generate data in a form suitable for many different protocols such as IrDA, LIN, Smart Card and Driver Enable for interfaces such as RS-485 and Modbus. This list, of course, does not exhaust the full capabilities of the USART interface. Additionally, it also has the same capabilities for realizing asynchronous transmission as UART, i.e.USART can generate the same type of serial data as shown in Figure 1 .

    USART and UART peripherals have definitely different possibilities and can be used in different situations, so in typical microcontrollers both of these interfaces are present so that the developer, when creating his system, can choose the one that best suits a given task. Take, for example, a system whose purpose is to run on low power. The device is to be based on the STM32 family. STM32 microcontrollers contain both USART and UART. USART is designed to implement serial communication with high requirements, especially since it consumes more energy. It can be activated when it is necessary to transfer large amounts of data or to run a complex protocol. On the other hand, when the microcontroller is asleep - in a low-power mode - the UART peripheral can handle low-speed communication while offering lower power consumption by the system.

    So are USART and UART the same? Technically, the answer is: not . USART generally has more capabilities than a standard UART module, as well as the ability to generate clocked data, allowing USART to run at speeds well in excess of UART's capabilities. USART covers the capabilities of the UART, however, in many applications, despite the high parameters of the USART module, programmers use them as simple UARTs, ignoring or avoiding synchronous clock generation in these powerful peripherals. No wonder so many people use these terms as if they were synonyms ...

    Source: https://www.edn.com/electronics-blogs/embedde...cs/4440395/USART-vs-UART--Know-the-difference

    Cool? Ranking DIY
    Can you write similar article? Send message to me and you will get SD card 64GB.
    About Author
    ghost666
    Translator, editor
    Offline 
    ghost666 wrote 11015 posts with rating 9359, helped 157 times. Live in city Warszawa. Been with us since 2003 year.
  • #3
    gregrzesiek
    Level 13  
    TechEkspert wrote:
    Is RS-485 a USART?

    RS485 is not the same as USART, but they can be related :)
    USART / UART - receiver / transmitter for serial data transmission. Here, the bit sequence, speed, data transmission format etc. are defined
    RS485 - defines the transmission from the electric side, voltage levels, differential transmission etc.

    Having the USART / UART interface, we can convert it to RS485 using an appropriate transceiver. Then the data format will be the same as in USART / UART, and the electrical levels as in RS485.
  • #4
    TechEkspert
    Editor
    However, it is quite tangled, i.e. both UART and USART can drive RS485?

    The only strong differentiator for me between USART and UART is the clock line between the devices.
  • #5
    gregrzesiek
    Level 13  
    TechEkspert wrote:
    However, it is quite tangled, i.e. both UART and USART can drive RS485?

    The only strong differentiator for me between USART and UART is the clock line between the devices.


    Yes, UART and USART can be connected to the RS485 transceiver.
    RS485 operates on one differential pair, so in this case no additional clock line is used. More important is that in UART the receiving device must know the speed at which it should receive data, e.g. in both devices (transmitter and receiver) we set the speed to e.g. 9600 baud. In the case of USART, the receiver is able to determine the baud rate from the received data.
  • #6
    TechEkspert
    Editor
    USART when:
    - the clock is passed on a separate line
    or
    - the device recovers the clock frequency from the transmitted data

    UART when:
    - the clock frequency is predefined and the clock is synchronized with the transmitted data
  • #7
    tmf
    Moderator of Microcontroller designs
    gregrzesiek wrote:
    More important is that in UART the receiving device must know the speed at which it should receive data, e.g. in both devices (transmitter and receiver) we set the speed to e.g. 9600 baud.

    Yes and no. By using asynchronous transmission, the receiver (some implementations even do it in hardware) has the ability to adapt the reception speed to the transmitter. In turn, using e.g. Manchaster coding in one transmission we have both clock and data.
    IMHO there is only one difference between UART and USART - UART supports transmission without an additional clock line, and USART allows the use of an additional clock line.
    ghost666 wrote:
    The use of an external clock allows for a much higher data transmission speed using the USART interface than the standard UART - this type of transmission reaches speeds of up to 4 Mbps.

    Technically, yes, and in practice, in many MCUs, the maximum baud rate for both modes is the same.
    ghost666 wrote:
    USART is much more complex and can generate data in a form suitable for many different protocols such as IrDA, LIN, Smart Card and Driver Enable for interfaces such as RS-485 and Modbus.

    Not necessarily. These additional functions depend entirely on the manufacturer's implementation. I would even risk saying that these additional protocols are an add-on not related to UART / USART, but only in many implementations using the UART / USART register set as they are similar serial protocols.
  • #8
    TechEkspert
    Editor
    The differential code manchaster is an interesting case, not only does it take care of a similar number of "0" and "1" in transmission, but also we have the clock synchronization of the receiver with the transmitter through the stream of information sent by the transmitter.
  • #9
    Marek_Skalski
    VIP Meritorious for electroda.pl
    ghost666 wrote:
    STM32 microcontrollers contain both USART and UART. USART ... It can be activated when it is necessary to transfer large amounts of data or to run a complex protocol. Conversely, when the microcontroller is asleep - in a low-power mode - the UART peripheral can handle low-speed communication while offering lower power consumption by the system.

    Sleep is just a halt to the core. Exactly for such applications as above, LPUART is dedicated, which consumes at least 2x less power and can operate in true energy saving modes. Another feature of LPUART is the ability to wake up the system in response to data sent from any level of the STOP mode. This is so as a supplement to the information, since we are already referring to a specific group of products.
  • #10
    krisRaba
    Level 31  
    LPUART is only in the L series? Do others also?
  • #11
    Sareph
    Level 24  
    krisRaba wrote:
    LPUART is only in the L series? Do others also?
    In others as well.
  • #12
    krisRaba
    Level 31  
    Interesting, I haven't found it so far. I will check in my free time to see if I just missed it or if the one I used was not there.
  • #13
    Sareph
    Level 24  
    They are in G0, G4, H7, L0, L4, L5, L6, WB55.
  • #14
    krisRaba
    Level 31  
    And here you have, I didn't use these at the time :-) But soon there will be H7 in the project, so I will read a bit about news :-)
  • #15
    osctest1
    Level 21  
    krisRaba wrote:
    it is supposed to be H7, so I will read a bit about news
    A lot of news :) . An interesting fact is that stlinkgdbserver can not get along with nini. OpenOCD and jlinkgdbserver absolutely
  • #16
    krisRaba
    Level 31  
    It's good to know in advance so that you don't tear your hair out later ;-)