Share this

Design of an Embedded USB Host System Based on TTL Serial Port

2026-04-06 03:13:32 · · #1
Abstract: This paper introduces an embedded USB host system based on a TTL serial port. The hardware implementation of the system and the underlying driver software implementation of the USB host are described, and its application in the field of data acquisition systems is briefly introduced. Keywords: Embedded USB host, TTL serial port, Mass storage, Class 1 Introduction With the development of the mobile storage industry and the popularization of digital products, the demand for mobile storage from data acquisition systems, industrial control industries, and embedded users is increasing, placing higher application requirements on mobile data storage disks. These applications include users in the geological and mining data acquisition industry, hydrological system data acquisition industry, instrument manufacturing industry, railway and long-distance transportation systems, oilfield data acquisition systems, single-board system software upgrade users, textile system data acquisition users, and banks, among others. However, because most data acquisition devices, industrial control computers, and embedded systems previously lacked standard USB data input/output interfaces, USB data storage has not been widely adopted. The needs of the industry and users have made the research of embedded USB hosts a new direction in the field of USB research. This paper introduces a USB host system based on a TTL serial port. The system uses a TTL serial port (or parallel port) to generate a USB interface, as shown in Figure 1. Embedded devices need to communicate and transmit data with the USB host system via the TTL serial port, following the USB host system's serial communication protocol. The host system is responsible for detecting the USB drive and storing data. This paper details the system's design concept and provides the hardware design and the design method for the USB host's underlying driver software. 2. USB Host Working Principle For designing an embedded USB host, we can refer to the USB host on a PC. For a PC's USB host, the hardware is controlled by a USB host interface chip, which communicates with the PC via the PCI bus, and also includes a power management section. The software mainly consists of three parts: the USB interface driver, responsible for communication between the CPU and the USB host interface chip, and responsible for receiving and sending low-level USB packets; the USB protocol stack driver, responsible for parsing various USB operation commands from the device driver and sending them to the low-level driver after decoding; and the device driver, which is the upper-level application, including the APIs provided by the operating system and user-defined operations on the USB device, such as sending device-specific USB command requests. Figure 2 shows the software architecture diagram of the USB host on the PC. 3. System Architecture The core chips of the entire system are Motorola's DSP56f803 and TDI's UHC124 USB HOST controller. The entire system consists of a DSP56f803 module, a UHC124 module, and a UART serial port module. 3.1 DSP56f803 Module The core controller of the system, including basic hardware and firmware. Its functions include: establishing physical connection and communication with the UHC124 and configuring the UHC124's control registers; configuring USB peripherals, implementing USB communication, fulfilling the configuration and data transmission requirements of the USB Host, accepting commands from the USB Host to manage USB peripherals; and implementing the FAT16 file system. 3.2 UHC124 Module USB HOST Controller Hardware Part. Implements the USB Host interface, configures downstream USB devices, and manages USB bus power. The implemented functions include: implementing various USB Host actions, coordinating various content functions, and communicating with the peripheral host controller; storing transmitted USB data and setting USB transmission characteristics; connecting to the DSP56f803 interface, which acts as the host controller; managing USB power; and connecting downstream USB devices, with a total of four downstream USB device ports. 3.3 UART Serial Port Module This is the firmware part that communicates with the user via a serial port protocol. It implements a custom serial communication protocol, that is, according to the custom serial communication protocol, it parses the serial communication data packets, calls the corresponding file operation interface functions, and implements the client's file operation commands. 4. Hardware Design 4.1 Hardware Architecture The main hardware modules include the USB HOST, the main control chip, external SRAM, decoding indicators, and the power supply. The main control chip is connected to the USB HOST chip, controlling the communication between the USB HOST chip and the mobile storage disk. Considering the need to reserve a data buffer for the user, external SRAM is used. Because the chips operate on different power supplies, two sets of DC power supplies are required. The decoding and indication circuit uses three LED indicators: one for power, one for indicating the connection of the removable storage disk, and one for indicating that the industrial control computer is communicating with the removable storage disk. 4.2 Selection of USB Host Controller Chip There are several options for selecting the host controller chip. As long as it has a UART interface, sufficient program storage space, and the program execution efficiency meets the system's functional requirements, it is acceptable. Currently, there are three main types of USB host controller chips on the market: Sypress's SL811, Philips' ISP1161, and TDI's UHC124. Among them, the SL811 is more common, and the author has used this chip in the development of the first-generation product. Considering various selection factors, the second-generation product uses the UHC124. The main advantages of the UHC124 over the other two chips are: support for packet transmission, allowing up to 16 USB protocol interaction data packets to be transmitted at once without generating an interrupt to the CPU, whereas the SL811 generates an interrupt every time, significantly consuming CPU resources; support for all USB transmission types, including control transfer, block transfer, interrupt transfer, and synchronous transfer, with a maximum data packet size of 1023 bytes; and a 2K data storage area. 4.3 Interface Circuit Connecting the Host Chip to the USB Host The UHC124 supports two memory access modes, depending on the level of the MODE pin. If the host chip has no external bus, mode 0 is used; if the host chip has an independent or multiplexed data and address bus, mode 1 is used. The host chip DSP56f803 selected in this solution has an independent address and data bus, therefore, mode 1 of the UHC124 is used. The interface circuit is shown in Figure 4 below. 5. Software Design The design of the USB host software can be referenced from the design of a PC's USB host. A simplified software flowchart of this solution is shown in Figure 5. 5.1 USB Interface Driver This driver primarily enables communication between the main control chip DSP56f803 and the USB host interface chip UHC124, as well as the reception and transmission of underlying USB packets. It forms the foundation for the entire USB system. The following functions are included: void ReadLengthFromHost(UCHAR ucaddr,UCHAR uclength,UCHAR *pucdata); void WriteLengthToHost(UCHAR *pucdata,UCHAR uclength,UCHAR ucaddr); UCHAR OutBulkData(ULONG ullength,UCHAR *pucptr); UCHAR InBulkData(ULONG ullength,UCHAR *pucptr); 5.2 USB Protocol Stack Driver This driver primarily implements the standard command requests defined by the USB protocol, including: ClearFeature(), GetConfiguration(), GetDescriptor(), GetInterface(), GetStatus(), SetAddress(), SetConfiguration(), SetDescriptor(), SetFeature(), and SetInterface(). For the specific meanings of these standard device requests, please refer to the USB standard protocol. The USB host must enumerate the USB devices upon detecting their insertion before the USB host and USB devices can enter normal data packet communication. 5.3 USB Device Class Drivers Removable storage disks belong to the Mass Storage class within the device classes defined by the USB protocol. The USB organization defines the specification for the Mass Storage Class, which includes four independent subclass specifications: 1. USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport 2. USB Mass Storage Class Bulk-Only Transport 3. USB Mass Storage Class ATA Command Block 4. USB Mass Storage Class UFI Command Specification. The first two sub-specifications define the methods for transmitting data/commands/status over USB. The Bulk-Only transport specification uses only the Bulk endpoint to transmit data/commands/status, while the CBI transport specification uses Control/Bulk/Interrupt endpoints for data/command/status transmission. The latter two sub-specifications define the operation commands for the storage medium. The ATA command specification is used for hard drives, while the UFI command specification is for USB removable storage. Therefore, the USB host needs to conform to the Mass Storage protocol to organize data and send commands to exchange data with the removable storage disk. 6. Conclusion The development of embedded USB hosts is still in its early stages, even internationally, with a limited number of available USB host interface chips. As another hot topic in USB bus research, embedded USB host research demonstrates a certain degree of advancement and forward-looking vision. Data acquisition systems centered on embedded USB hosts can be widely applied in both industrial and consumer fields, bringing considerable economic benefits and market prospects.
Read next

CATDOLL 128CM Cici Silicone Doll

Height: 128 Silicone Weight: 21kg Shoulder Width: 30cm Bust/Waist/Hip: 57/52/63cm Oral Depth: N/A Vaginal Depth: 3-15cm...

Articles 2026-02-22