Research and Design of UART on TMS320VC5402 and PC
2026-04-06 06:25:32··#1
1. Introduction The TMS320VC5402, with its low cost, low power consumption, and abundant resources, has been widely used in communication and control fields. It integrates up to 192kB of on-chip storage (64kB RAM, 64kB ROM, 64kB I/O), and features a time-division multiplexed serial port (TMD), two buffered serial ports (BSP), an 8-bit parallel host interface (HPI), and a programmable wait state generator, fully meeting data processing and control requirements. The design of various data communication interfaces is essential in application systems built on the 5402. Compared to parallel ports, serial interfaces reduce the number of device pins, saving hardware system size and reducing interface design complexity. In practical applications, asynchronous serial data transmission and communication between systems are required. The DSP5402 has a synchronous serial port, which differs from standard asynchronous serial interfaces. This paper designs and implements asynchronous serial communication between the DSP5402 and a PC for this application. 2. Serial Communication and DSP5402 Serial Port Serial communication is widely used in industrial control and practical applications. Figure 1 shows three common RS-232 communication methods. Here, we choose the short-distance wired transmission method. Currently, most PC serial ports use the RS-232 standard, which specifies a 25-pin DB25 connector. However, many of the 25 pins of RS-232 are rarely used. Therefore, the most commonly used serial ports are 9-pin and 25-pin. In ordinary circuit design, the simplest and most commonly used method is the three-wire connection. This method eliminates the need for RS-232 control signals during communication. Instead, it uses a three-pin connection of transmit data (TXD), receive data (RXD), and ground (GND) to achieve full-duplex asynchronous serial communication. This method is used in this paper to implement serial communication between the PC and the DSP. [align=center]Figure 1 Three RS-232 Communication Methods[/align] Since RS-232 does not have a clock signal, it transmits data at a fixed baud rate. A signal includes a start bit, a stop bit, and data bits; a parity bit is optional. The data bits are 5-8 bits, and the parity bit has 5 options: odd parity, even parity, always 1, always 0, and empty; the stop bit also has 3 options: 1 bit, 1 1/2 bits, and 2 bits. Serial data transmission prioritizes the least significant bit, with the start bit indicating data transmission. The DSP5402 has two multi-buffered synchronous serial ports, controlled by frame signals. Each serial port has 6 signals: CLKR/X: receive/transmit clock signal, DR/DX: receive/transmit serial data signal, and FSR/FSX: receive/transmit frame synchronization signal; the serial interface has 5 registers: Data Receive Register (DRR), Data Transmit Register (DXR), Serial Interface Control Register (SPC), Data Receive Shift Register (RSR), and Data Transmit Shift Register (XSR). Three memory-mapped registers (SPC, DXR, and DRR) and two registers not directly accessible by the program (RSR and XSR) are used for operation. RSR and XSR are useful when performing double buffering. Data is sent to DXR and received from DRR. For the configuration and control of each register, please refer to reference [2]. 3 Hardware and software implementation of serial communication between DSP and PC 3.1 Hardware connection of UART between DSP and PC As mentioned above, the asynchronous serial port of PC and the synchronous serial port of DSP5402 are different in data format and transmission control, but communication between DSP5402 and standard serial port can be realized through necessary hardware control and software simulation. There are two hardware methods and two software simulation methods for the implementation of UART between DSP5402 and PC. The hardware methods are as follows: synchronous to asynchronous implementation based on MAX3100 and timing simulation method using DSP5402 I/O. MAX3110E integrates a full-function UART and an RS-232 transceiver with built-in electric pump capacitor and ±15kV ESD protection. Among them, the UART part adopts a serial interface compatible with SPITM/QSPITM/MICROWIRETM, thus saving circuit board space and microcontroller I/O pins. Because the RS-232 section uses a unique low-dropout output stage, the dual receive/transmit interface can provide true RS-232 characteristics under high-speed communication and normal power supply, while consuming only 600μA. The MAX3110E enables the conversion from a synchronous serial data interface to an asynchronous serial communication port (RS-232), and it can be directly connected to the PC's serial port (COM). The MAX3110E features small size, low price, low power consumption, and high communication speed, thus having good application prospects. The MAX3110E consists of two independent parts: UART and RS-232. The UART section includes an SPI-compatible serial interface, a programmable baud rate generator, a transmit buffer and transmit shift register, a receive buffer and receive shift register, an 8-byte receive FIFO, and an interrupt generator with four maskable interrupt sources. The RS-232 section includes a built-in capacitor-equipped pump, which can be hardware-disabled by SHDN. The MAX3110E communicates with the DSP5402 via the SPI interface for 16-bit full-duplex data transmission. The 16-bit serial data sequence sent by the DSP5402 to the MAX3110 via the BDX line includes transmission format control words, such as baud rate settings, interrupt masking, and parity bits. When the DSP5402's McBSP serial interface is operating in SPI mode, it can be directly connected to the MAX3110. The DSP5402's BDX1 is connected to the MAX3110's DIN as the transmit data line, and BDR1 is connected to DOUT as the receive data line. The transmit synchronization pulse signal BFSX1 is used as the chip select signal, and the transmit clock signal BCLKX1 is used as the serial clock input of the MAX3110. The hardware interface diagram is shown in Figure 2: [align=center] Figure 2 Hardware Interface Diagram of DSP5402 and MAX3110[/align] Simultaneously, the DSP5402's McBSP register must be configured according to the timing diagram for this UART mode to be implemented. The timing diagram is shown in Figure 3: [align=center] Figure 3 Timing Diagram of MAX3110 and DSP5402[/align][align=left] The timing analysis using the DSP5402 I/O simulation method is as follows: Timer interrupts are used to process data, and I/O ports are used for configuration as input and output. Since the DSP5402 has few individual I/O pins, to save resources, the DSP5402's flag pin XF is used here in conjunction with software to achieve the desired result. The hardware schematic is shown in Figure 4: Figure 4 Hardware Schematic Diagram 3.2 DSP and PC UART Software Implementation The DSP5402 programming for synchronous-to-asynchronous conversion based on MAX3100 is as follows: stm SPCR11, SPSA1; Configure SPCR11 stm #1800h, MCBSP1 stm SPCR21, SPSA1; Configure SPCR21 stm #0000h, MCBSP1 stm PCR1, SPSA1; Configure PCR1 stm #0a0ch, MCBSP1 stm RCR11, SPSA1; Configure RCR11 stm #0040h, MCBSP1 … … ; Configure RCR21 stm XCR11, SPSA1; Configure XCR11 stm #0040h, MCBSP1 … … ; Configure XCR21 stm SRGR11, SPSA1; Configure SRGR11 stm #0027h, MCBSP1 … … ; Configure SRGR21 rpt #20 ; Wait for 2 CLKSRG clock cycles nop stm SPCR21, SPSA1 ; Configure SPCR21 stm #0040h, MCBSP1 ; Start MCBSP1 sampling rate generator rpt #20 ; Wait for 2 CLKG clock cycles nop stm SPCR11, SPSA1 stm #1801h, MCBSP1 ; Start receive stm SPCR21, SPSA1 ; Configure SPCR21 stm #0041h, MCBSP1 ; Start MCBSP1 transmitter stm SPCR21, SPSA1 ; Configure SPCR21 stm #00c1h, MCBSP1 ; Start frame synchronization pulse rpt #80 ; Wait for 8 CLKG clock cycles nop ld? #0h, A stm #0c042h, DXR11; Configure MAX3110. Once the two stop bits are configured, data can be sent. The receiving program only needs to configure the corresponding receiving register according to the mode. Figure 5 shows the test interface. [align=center]Figure 5 Serial Port Debugging Assistant Test Interface[/align] For I/O simulation software programming, the communication baud rate can be set through timer interrupts. For DSP5402 timing, the three registers TIM0, PRD0, and TCR0 need to be set. Timing time = TX(1+TDDR)X(1+PRD). At the same time, the communication baud rate can also be set through software delay, as follows: DELAY: stm #1004h, AR6; Communication rate: 1200bps banz $, *AR6- nop ret. The software simulation program is shown in Figure 6. Both software simulations need to be tested on a PC using a serial port debugging assistant. The author implemented the test interface as shown in Figure 6. In order to meet the needs of practical applications, you can use VC to write your own software. [align=center]Figure 6 Software Simulation Program[/align] 4 Conclusion This paper mainly discusses the methods for implementing UART between TMS320VC5402 and PC. Utilizing synchronous serial ports is simple, easy, and stable; software simulation does not require dedicated hardware, is flexible, convenient, and low-cost, and each method meets its own needs. Both methods have been tested and proven successful. This approach has certain reference value for the research of DSP5402 and serial ports. Editor: He Shiping