ST AN2781 Application note UART emulation software in STM8S STM8A microcontrollers handbook

This application note describes how to emulate the UART behavior and functionality using routines in STM8S microcontrollers. The UART peripheral is emulated on hardware that has the capture & compare interrupt capability. Such emulation is useful in applications that require more than one UART, or when the dedicated serial communication hardware peripherals are being used in another way. This software solution is suitable for standard full-duplex speeds of up to 57 600 Bd for the core running at 24 MHz or, of up to 19200 Bd for the core running at 16 MHz. Its main feature is that it runs in the background with a time reserve, so that the main process stream can continue and control the rest of the application processes. The higher communication speeds can be achieved when polling and controlling I/O pins in the main stream, but, as a result, the control of all other application processes is sidetracked while receiving or sending a message and the full-duplex capability might even be lost. Standard data frame formats are supported, as well as options like parity, ninth data bit and double stop bit. Double data registers, noise detection logic, frame generation and overflow logic are implemented with minimum MCU hardware usage. A firmware package is delivered with this document. It contains the complete C source code so that the user can compile.


ST AN2781 Application note UART emulation software in STM8S STM8A microcontrollers handbook - cover page
Brand
STMicroelectronics
Category
microcontrollers
Document type
Application Note
Language
English
Pages
14
File format
PDF
File size
102 KB
Published
07 August, 2012
Updated
28 September, 2023
Models
STM8S, STM8A
MD5 checksum
0B6C546FBF8F8D79745B1F6DE928DA5B

About this manual

This document describes a software solution for emulating UART functionality in STM8S and STM8A microcontrollers. The emulation is implemented using a single CPU capture & compare timer, allowing the UART peripheral to be used for other purposes or enabling multiple serial ports. The solution supports standard full-duplex speeds up to 57,600 Bd at 24 MHz or 19,200 Bd at 16 MHz, running in the background to minimize impact on the main application process.

What's inside

  • Principle of the software solution
  • User interface
  • Application interface
  • Precompile interface
  • Firmware package
  • Test environments
  • CPU workload
  • Other solutions
  • Revision history

Specifications

Maximum baud rate (24 MHz core)57,600 Bd
Maximum baud rate (16 MHz core)19,200 Bd
Supported data formatsStandard data frame formats, parity, ninth data bit, double stop bit
Development environmentST Visual Develop (STVD) and Cosmic compiler
Minimum STVD version3.5.0

Frequently asked questions

What microcontrollers does this software support?

The software is designed for STM8S and STM8A microcontrollers.

How is the UART emulation implemented?

It uses routines in the microcontroller that utilize the capture & compare interrupt capability.

What is the maximum communication speed for a 24 MHz core?

The maximum speed is 57,600 Bd for a core running at 24 MHz.

Download PDF (102 KB)

More STMicroelectronics Manuals


View all STMicroelectronics manuals →