
Abstract:Most digital signal processor (DSP) chip, not to mention on behalf of the Universal Asynchronous serial transceiver (UART), only 2 to 3 synchronous serial interface, computer and other equipment with serial communication, must be extended asynchronous serial interface on the DSP. TI, the United States TMS320C54XX series DSP, for example, MAXIM's MAX3111 uses asynchronous serial transceivers, interface extension of the ideal solution. This program discusses the software and hardware. The program is simple hardware connection, software programming convenience, can be achieved between the DSP and PC, serial communication, with a high engineering value.
DSP in the electronics industry has been more widely used. DSP applications in the design, it is essential that the design of various communication interfaces. Compared with the parallel interface, serial interface, the most important feature is to reduce the device pin count, reduced complexity interface design. Serial data transmission can be divided into synchronous and asynchronous modes. Universal RS-232 PC-interface for universal asynchronous interface UART (Universal Asynchronous Receiver and Transmitter), the MOTOROLA company's serial peripheral interface SPI, queue SPI (QSPI), PHILIPS company's internal IC bus (I2C), National Company micro-bus (MICROWIRE) are synchronous serial protocol.
Almost all of the digital signal processor provides one or more serial interfaces, however, most DSP chips are synchronous serial port. In practical applications, the DSP also need to be able to communicate with the asynchronous serial peripherals, such as with PC, requires the serial data transmission system with DSP UART serial interface. In response, this paper and implemented a simple, reliable method for asynchronous serial port expansion.
An extended program
DSP applications in a comprehensive analysis of asynchronous serial interface, the program expanded, the basic methods and the advantages and disadvantages are as follows:
(1) parallel bus in the DSP extended UART chip (such as TI's TL16C552), asynchronous data transfer in hardware. Advantage is that software is simple, the disadvantage is the need to expand other devices on the bus, the target system to do complex, increasing the system volume.
(2) the use of DSP's McBSP and DMA, in the case does not extend other hardware, using software asynchronous data transfer format. This method has the advantage of simple hardware, but software complexity, and increased the burden on CPU, so the large amount of data is not suitable for communication applications.
(3) the use of DSP's McBSP synchronous serial interface, the appropriate hardware in the expanding case, the synchronous data format conversion for the UART asynchronous data transmission. Thus, full use of on-chip DSP resources to try to simplify the hardware system.
Considering the hardware connection and software programming convenience, we adopt the third option, the application U.S. serial asynchronous MAXIM's MAX3111 transceivers, and the DSP's McBSP port directly connected. Without any other external hardware devices, and because the sending and receiving asynchronous data from the MAX3111 to implement hardware solutions, software programming needs to be considered so the only synchronization between the DSP and the MAX3111 data communication. Thus, with the most simple hardware connection and software programming can be synchronized to the asynchronous serial data format conversion.
2 SPI interface protocol and DSP multi-channel buffered serial interface
2.1 SPI Interface Protocol
Serial Peripheral Interface (SPI) is the MOTOROLA company's proposed a synchronous serial peripheral interface, allowing CPU with a variety of external serial interface device to communicate and exchange information. It uses four lines: a serial clock line (SCK), Master Input / Slave Output line (MISO), master output / slave input line (MOSI), active-low enable signal line (CS). Thus, only 3 to 4 data lines and control lines can be extended with the SPI interface to a variety of I / O devices. The typical interface shown in Figure 1.
2.2 McBSP functions and features
TMS320C54XX series DSP chip has 2 to 3 high-speed, full-duplex, multichannel buffered serial port (McBSP), its ease of data flow control can make it with most synchronous serial peripheral interface. McBSP serial interface is a standard function on the basis of expansion, in addition to features with a standard serial port, its flexibility is reflected in the following aspects:
(1) double buffer to send, three buffer received
continuous data stream;
(2) with SPI, IOM-2, AC97-compatible devices such as direct interface;
(3) Programmable frame sync, data clock polarity, support for external shift clock or an internal programmable frequency shift clock;
(4) has separate transmit and receive data and clock signal frame synchronization pulses;
(5) multi-channel transmit and receive up to 128 channels, the speed for the 100Mbit / s.
2.3 McBSP in SPI mode
TMS320C54XX series DSP chip McBSP serial port working on the clock stop mode is compatible with the SPI protocol. When the McBSP is configured to clock stop mode, the transmitter and receiver are internally synchronized, then McBSP as SPI master or slave device. Send a clock signal (BCLKX) corresponds to the SPI serial clock signal Agreement (SCK), send the frame synchronization signal corresponding to the enable signal from the device (CS). In this way the received clock signal (BCLKR) and receive frame synchronization signal (BFSR) will not make the connection, because they are internally connected with the BCLKX and BFSX. McBSP operating in SPI mode host, with other SPI device interface shown in Figure 2.
3 MAX3111 UART
3.1 MAX3111 Features
MAX3111 UART is MAXIM specializes in micro-processing system for small to optimize the design of the UART, which includes an oscillator and a programmable baud rate generator; has a maskable interrupt sources; the other with an 8-byte receive FIFO (first in first out) buffer. It uses SPI / MICROWIRE interface technology to communicate directly with the host controller, the line is simple, small size, communication speed up to 230kbit / s. Another addition to the internal UART, but also includes two RS-232 level converter, so no need to access common MAX232 level converter, you can apply a chip microcontroller (with SPI / MICROWIRE interface) machine or other device with the PC between the asynchronous data transmission.
3.2 MAX3111 operation
MAX3111 via SPI interface with master device 16-bit full-duplex synchronous communication of data, or main facility to transmit 16-bit data to the MAX3111, but also to the MAX3111 can receive a 16-bit data transmission. MOSI line in the master sent to the MAX3111 16-bit serial data transmission format in the sequence, including the control word, such as the baud rate of equipment and interrupt mask, parity, etc., as well as sending the data word. MAX3111 in the MISO line to the master device sends 16-bit data sequence, in addition to the received data, but also includes interrupt flags and other status bits. Therefore, real-time through the 16-bit data transfer, the master work of state information available MAX3111 also has full control of their rights. Thus, the control of two devices, status, real-time data communications to ensure the reliability and stability of data transmission.
4 DSP Interface Design with the MAX3111
DSP's McBSP serial interface to operate in SPI mode to connect directly with the MAX3111 to achieve devices with RS-232 asynchronous data transmission. At this point in the DSP as an SPI master agreement, the interface circuit shown in Figure 3.
DSP transmit clock signal (BCLKK) as the MAX3111 serial clock input, send the frame synchronization pulse signal (BGSX) as the MAX3111 chip-select signal (CS). BDX and DIN connector for sending data line, BDR with DOUT connected as a receive data line. MAX3111's TX and T1IN connection, RX and R1OUT connection to take advantage of the on-chip realization of the converter to the RS-232 UART level translation. MAX3111 interrupt signal (IRQ) is connected with the DSP's external interrupt.
In the SPI serial protocol, the master clock signal and control data transfer process. MAX3111 interface circuit by the timing diagram (Figure 4) shows that DSP's McBSP must be set in the appropriate way to ensure timing compatible with the MAX3111.
MAX3111 requires data transmission CS signal must be low, after the transfer must be high. This signal is provided by the McBSP's BFSX pin, so the frame must be set correctly DSP pulse generator, so that each data packet transmission in the frame synchronization pulses generated during, that the first data packet transmission becomes active, then to maintain this state until the end of packet transmission.
McBSP sample rate generator clock frequency properly by BCLKX pin to ensure synchronization between the master and slave data transmission. DSP must be properly set so the sample rate generator clock source (CLKSM) and the clock down-factor (CLKGDV). According to SPI transfer protocol, data transmission must be properly set delay time (XDATDLY). Figure 4 shows the MAX3111 requires a half SCLK goes high between the beginning of the cycle to transmit data.
Therefore, we must choose the right clock for the McBSP program, which set the McBSP clock stop mode. Used in this application McBSP clock stop mode 2 (CLKSTP = 11b, CLKXP = 0), so the timing can be guaranteed compatible with the MAX3111.
5 DSP software design of asynchronous communication
Taking into account the application software portability and readability, the data transmission software written using C language, so that you can use DSP development software provided by CCS2.0 DSP / BIOS in the chip support library functions (CSL). CSL provides C-callable DSP library function peripheral interfaces, including the DMA module, McBSP module, TIMER module. Application of these library functions can greatly improve the readability and shorten the software development cycle. Applications mentioned in this article, the main call MCBSP module. Data transfer software includes the following sections.
(1) McBSP serial port initialization
As mentioned above, in this application should TMS320C54XX DSP's McBSP serial port configured for SI mode to DSP as the main equipment. Table 1 shows the register or the register should be set to bit value, not covered by the register to maintain their default values.
According to Table 1, the McBSP configuration CSL call library functions to complete the McBSP initialization.
McBSP_Handle hport0; / * statement handle to point to McBSP * /
McBSP_Config PortConfig = {/ * register settings define the structure * /
0x1800, / * set the value of the serial port control register 1 * /
0x0000, / * set the value of the serial port control register 2 * /
0x0040, / * Receive control register set the value * /
...
};
hport0 = MCBSP_open (0, MCBSP_OPEN_RESET); / * open the first McBSP serial port * /
MCBSP_config (hport0, & PortConfig); / * set the McBSP by the structure of the register * /
(2) MAX3111 mode and baud rate settings
Before carrying out communications, DSP must first under the command sequence format configuration commands to the MAX3111 written word, before it can correct data transmission, such as the 8 data bits, one stop bit, no parity, baud rate is 115200 so that it can receive and send asynchronous data transmission interruption. DSP configuration of the MAX3111 is a brief procedure:
...
McBSP_start (hport0, / * McBSP start data transfer * /
McBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC
| McBSP_RCV_START | MCBSP_XMIT_START, 0x200
);
while (! McBSP_xrdy (hport0 ));/* waiting to send register is empty * /
McBSP_write16 (hport0, 0x6E0B); / * write to the MA3111 configuration command word * /
...
(3) interrupt service routine
During the interrupt data transfer, you need to note: Although the DSP's McBSP has its own transmit and receive interrupt, but between the McBSP and the MAX3111 synchronous serial data transfer rate higher than the MAX3111 data to a certain baud rate ( maximum 230kbps) asynchronous transmission rate, so if the application McBSP transmit interrupt will cause the loss of transmit data. Meanwhile, in the SPI protocol, data transmission is initiated by the SPI master device, so in the SPI mode of the McBSP receive interrupt can not. Therefore, one of the key application of this program is to MAX3111's IRQ interrupt signal is connected to a DSP external interrupt, the interrupt mode in order to achieve reliable and correct data transmission.
Existing data for multi-digital signal processor (DSP) chip does not provide asynchronous serial transceiver (UART) interface, and only synchronous serial interfaces. In this paper, a simple hardware interface to convert the synchronous asynchronous serial interface, full use of the DSP hardware in the chip data, a good solution to the DSP's asynchronous serial port expansion problem. This method has been applied in engineering practice. Practice has proved that, in a variety of baud rates (up to 230.4kbps), the query and interrupt data transmission is correct, reliable, and all components working properly, and in this connection, based on the hardware, the use of DSP's DMA function string receive and transmit data line received good results, and further enhance the performance of the application system.