Introduction
First of all, the serial port is an essential tool for anyone involved in hardware and embedded software, especially for debugging systems with MCUs or CPUs. During the debugging process, the first thing we usually do is to light up a GPIO. This has been covered in our previous content.
From schematic PCB to porting RTOS In-Depth Analysis of STM32 Part Three GPIO
After completing the GPIO lighting, we generally hope to implement serial port printing functionality, which allows us to print out some register information for easier debugging.
Due to my unique experience, I could write a book on serial ports! It should be no less than 200 pages.
In 2008, when I first joined Huawei, I encountered a unique historical period where various players were competing in the embedded field.
1. Intel and AMD boldly claimed that the X86 system was entering the embedded field to capture the PowerPC market. (Later, Intel succeeded, as general-purpose servers dominated almost all telecom core-side devices—blade servers, rack servers).
2. At that time, MIPS, ARM, and PowerPC were closely matched, but multi-core ARM was immature and could not be widely applied in the telecom field. MIPS initially stood out due to its excellent cost-performance ratio but gradually faded due to poor quality performance.
3. PowerPC, under pressure from other processors, also began to launch multi-core processors.
My job at that time involved participating in the development of X86 processors as embedded circuits. I encountered a problem: the traditional X86 architecture had evolved very maturely as a PC. The hardware structure of PCs is significantly different from that of embedded SoCs.
Below the CPU is the Northbridge, responsible for high-speed peripherals, while the Southbridge (below) is responsible for low-speed interface peripherals, and there is also an SIO responsible for even lower-speed peripherals.
SIO stands for Super I/O.
The Super I/O chip (SIO) is generally located at the lower left or upper left of the motherboard. The main chips used are Winbond and ITE, which provide control processing functions for standard I/O interfaces on the motherboard. The term “Super” refers to its integration of processing functions for PS/2 keyboard, PS/2 mouse, serial COM, parallel LPT interfaces, etc., all of which are slow I/O devices in computers. They are all located at the back right of the motherboard. Its main functions include processing serial data transmitted from devices such as keyboards, mice, and serial interfaces, converting them into parallel data, and also handling the transmission and processing of data from parallel interfaces and floppy disk interfaces. SuperIO connects to the Southbridge via a simplified PCI bus called the LPC bus.
This complex hardware structure is also due to Intel’s strong shipment volume, forming its own system and standards.
Therefore, on traditional PC motherboards with an RS232 serial port, it is all implemented through SuperIO. The X86 also accesses it through fixed addresses.
In contrast, the ARM architectures we are familiar with, whether Cortex-M or Cortex-A, all have serial ports—UART integrated into the MCU or CPU.
From the structural block diagram of the STM32F103 MCU selected by iBox, we can see a number of UARTs and USARTs.
However, in the design requirements of the embedded X86 system I faced at that time, there was no need for parallel ports, PS2, hardware monitoring, or FDC.
H/W Monitor: An application program reads all measurement values from hardware sensors accessed by the computer.
FDC: Provides an interface between the main processor and the floppy disk drive (floppy disk—those who understand this are revealing their age).
Parallel port: There are four modes: Standard Parallel Port (SPP), Bi-directional Parallel Port (BPP), Enhanced Parallel Port (EPP), and Extended Capabilities Port (ECP). The input/output mode can be controlled via DIR.
Those who recognize the above image are again revealing their age.
KBC: The circuit provides functions including a keyboard and a PS2 mouse. The controller accepts serial data from the keyboard and mouse, checks for parity, and outputs this data to its output buffer. Basic settings can be understood from its read/write commands.
UART: Finally, we come to the main character of this article, the UART, or serial port. In old desktop computers or laptops, there is usually a UART that conforms to the RS232 voltage standard:
We have previously published related content on various voltage standards for serial ports:
UART, RS-232, RS-422, RS-485
The UART output from SuperIO is generally also TTL level, which needs to be connected to an RS232 chip, and then to a DB9 interface.
The addressing space of the X86 system is somewhat complex: in addition to memory space, there is also I/O space. For detailed content, click:
Processor Series (7) – Addressing Space
The I/O space is
In X86 development, low-speed peripherals such as serial ports are accessed and read/written using I/O space:
From the UART Device Configuration Registers, we can see that the base addresses for UART1~UART4 are 03F8H, 02F8H, 03E8H, and 02E8H respectively.
GPIO: General Purpose Input/Output
ACPI: ACPI is a system for controlling computer power.
For traditional telecom embedded systems implemented by PowerPC, apart from the serial port, other functions are not needed; at the same time, some NorFlash, registers, and sensor data need to be accessed via the MPI interface, which cannot be achieved by SuperIO chips.
Additionally, due to the multifunctionality of SuperIO, it is large in size and has many pins.
Therefore, in the design requirements at that time, using a SuperIO was not suitable. So, we chose a CPLD to implement the LPC interface control for the UART interface.
Since I have worked on such a project, I am particularly familiar with the working process of UART. Moreover, we initially customized many registers according to our ideas, and the addresses were designed based on our preferences, resulting in commercial software like Windows and commercial Linux being unable to directly recognize the serial port. Later, we reverted to the base addresses: 03F8H, 02F8H, 03E8H, and 02E8H.
I am already tired before finishing the introduction…
Next time, I will continue to discuss serial ports with everyone.