STMicroelectronics AN2800 STM8A UART Emulator Application Note

This application note describes a technique to emulate the universal asynchronous receiver transmitter (UART) hardware peripheral, through the microcontroller medium end timer (TIMER3), without the use of additional hardware. TIMER3 was chosen for this purpose because its capture and compare features can be easily used to receive and transmit data in a non return to zero (NRZ) serial format. This timer also provides a necessary time reference to establish when to send and read each outgoing and incoming data frame bit. In addition, TIMER3 was chosen because it has all the necessary features to build a software UART. Features include two timer channels, one for transmission (TIMER3_CC2) and one for reception (TIMER3_CC1). The input capture feature of channel one allows detection of an incoming data frame start bit, whereas its compare feature indicates when the bits have to be read. The output compare feature of channel two allows transmission of a data frame. The algorithm described in this document is an example which can be further customized and improved. It is explained in Section 7: The UART emulator software algorithm on page 14, together with information on how to configure and use a UART emulator. The algorithm handles several UART hardware features via software such as, selection of the operating mode, noise and frame error detection, programmable data word length and configurable stop


STMicroelectronics AN2800 STM8A UART Emulator Application Note - cover page
Brand
STMicroelectronics
Category
microcontrollers
Document type
Application Note
Language
English
Pages
33
File format
PDF
File size
912 KB
Published
07 August, 2012
Updated
29 September, 2023
Model
STM8A
MD5 checksum
879DFAB74E16AAF957C3D2C9D9A84386

About this manual

This document details a software-based method to emulate the Universal Asynchronous Receiver Transmitter (UART) hardware peripheral on STM8A microcontrollers. The emulation is achieved using the medium end timer (TIMERS) without requiring additional hardware. The technique utilizes the timer's capture and compare features to handle data reception and transmission in a non-return-to-zero (NRZ) serial format.

What's inside

  • Main features of the UART emulator
  • UART communication protocol
  • UART data frame description
  • Data transmission
  • Data reception
  • Baud rate generator
  • UART emulator software algorithm
  • Connecting the UART emulator to a PC

Specifications

Transmitter mode speedup to 28800 bits per second (bps)
Receiver mode speedup to 28800 bps
Data word lengtheight or nine bits
Stop bitsone or two stop bits

Frequently asked questions

How is the UART emulator implemented?

The UART emulator is implemented through the microcontroller medium end timer (TIMERS) without the use of additional hardware.

What error detection features are included?

The emulator includes two error detection flags: a Noise error (NF) flag and a Frame error (FE) flag.

How does the receiver handle noise?

The receiver uses a majority voting system where three samples are taken from the middle of each bit to determine the bit value.

Download PDF (912 KB)

More STMicroelectronics Manuals


View all STMicroelectronics manuals →