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.
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.
| Maximum baud rate (24 MHz core) | 57,600 Bd |
|---|---|
| Maximum baud rate (16 MHz core) | 19,200 Bd |
| Supported data formats | Standard data frame formats, parity, ninth data bit, double stop bit |
| Development environment | ST Visual Develop (STVD) and Cosmic compiler |
| Minimum STVD version | 3.5.0 |
The software is designed for STM8S and STM8A microcontrollers.
It uses routines in the microcontroller that utilize the capture & compare interrupt capability.
The maximum speed is 57,600 Bd for a core running at 24 MHz.