Authors: Qi Chongying, Chen Xihong, Su Hongchao
TMS320C3x DSP is one of the most widely used DSP chips in China. It provides a serial interface that can communicate with external serial devices, supports 8/16/24/32-bit data exchange, and is designed for A/D, D/A The interface circuit provides great flexibility. However, when the DSP system communicates with the PC, how to design a reasonable interface circuit and communication software to accurately transmit the data processed by the DSP to the PC in real time, while enabling the PC to effectively control the DSP in real time, which becomes the DSP system design An important link in the This article adopts asynchronous serial communication (Universal Asychronous Receiverand Transmitter, UART), which solves the problem of DSP and PC communication.
2 Introduction to TMS320C3x
TMS320C3x (hereinafter referred to as C3x) is the third-generation product produced by TI (TexasInstruments) and the first-generation floating-point DSP chip, including C30, C31, C32 and C33. It is one of the TMS320 series with higher performance and price. The floating-point DSP chip has 32-bit floating-point precision. There are three sets of buses, namely the program bus, the data bus and the DMA bus. The instruction fetching, reading and writing data and DMA operations can be performed in parallel, and can address a space of 16M words. Among them, C31 is a simplified and improved version of C30. It removes the expansion bus and a serial port, reduces the cost of the chip, and adds a very useful function to the hardware, namely the program boot function (Bootloader), so that the program can be downloaded from Low-speed EPROM, PROM, or serial port is loaded into the high-speed RAM of the system to run at full speed. C32 and C33 are further simplifications and improvements of C31, in which C32 on-chip RAM is reduced to 512 words to reduce costs. The on-chip RAM of C33 is 34K and requires 3.3V power supply.
3 DSP system structure block diagram
Figure 1 shows the hardware block diagram of the entire DSP system.
Among them, TLC32044 is one of the TLC32040 series of analog-to-digital interface chips (AIC for short) produced by TI. It integrates A/D and D/A. It has two analog input ports and one analog output port, the highest sampling The frequency is 19.2kHz. MC6850 is an asynchronous serial interface chip (UART) produced by Motorola. It can send and receive 8-bit or 9-bit data, and can choose three different clock modes: ÷1, ÷16, and ÷64. DSP sets up the asynchronous communication protocol by initializing the control register of MC6850, and then MC6850 performs parallel-to-serial conversion on the parallel data of the DSP and the serial data of the PC according to the protocol. MAX232 chip carries on the conversion between TTL level and RS-232 level. The external signal enters the DSP through the A/D conversion, and after the DSP processes it, it is sent to the PC via the UART, and the data is processed and stored by the PC. At the same time, the PC sends the control signal or data to be sent to the DSP via the UART, controls the DSP or sends it to the D/A after being processed by the DSP, and returns to an analog signal after low-pass filtering.
4 DSP system communication software
During transmission, the sending parties should initialize in accordance with the mutually followed agreement. The communication protocol adopts the start-stop asynchronous communication protocol. The following are the source code for the initialization operation of the DSP on the MC6850 and the upper-layer PC software on the serial port.
4.1 MC6850 asynchronous serial port communication program design
After powering up, the 6850 is in a locked state to avoid sending output errors. Before use, the CR0 and CR1 of the control register must be set to “1” by the program to perform a master reset and release it from the locked state. Then you can program the control register to determine the 6850’s clock division, data format, and send and receive control functions. The following is a program to initialize the 6850 and send data in C language under the Code Composer integrated development environment.
4.2 PC communication program design
In the VC + + 6.0 environment, there are two common methods for serial communication using a PC: (1) Calling Windows API (Application Program Interface) functions; (2) Using ActiveX’s MSComm control. The first method needs to declare and call many API functions, which is very cumbersome. Therefore, this article adopts the second method.
The specific realization process of PC communication is as follows:
The first step is to start VC++ 6.0 and create a new dialog-based application TxRx.
The second step is to insert serial port controls in the dialog box, add new static text, edit box and button controls, and add corresponding variables for them. Its properties are as follows:
Secondly, you need to initialize the serial port parameters. Add the following code after the TODO statement in the OnInitiDialog() function:
//Read the buffer first to clear the residual data
Next, add a message processing function OnTransmitt() for the send button IDC-TRSMITT, the content is as follows:
The following example illustrates how to send a frame of data in the Transmitt() function.
5 concluding remarks
The above is the software and hardware solutions for asynchronous serial communication between DSP and PC. At present, this solution has been applied to the data transmission system of shortwave communication intelligent terminal. It has stable operation and good communication performance. It has solved the problem of DSP and PC. Communication problem.