This paper introduces the principle of vk32 series universal asynchronous serial transceiver (UART), which is specially designed for embedded system, and its application technology in tax controlled POS, remote automatic meter reading system, embedded vehicle information platform and serial port server.
UART was produced in the 1970s and is the first large scale integrated circuit. In 1981, IBM PC adopted 8250 UART to communicate with peripherals. Until the end of last century, UART was the most important serial communication interface in PC. With the emergence of high-speed serial bus USB, USB has replaced UART and become the most widely used serial interface in personal computers.
In the field of embedded system, because UART has the advantages of simple operation, reliable operation, strong anti-interference and long transmission distance (485 network can transmit more than 1200 meters), designers generally believe that UART is the best way to transfer data from CPU or microcontroller to other parts of the system, so they are widely used in embedded fields such as industry, communication and home appliance control. Usually MCU / CPU will bring a UART serial port, but in practical application, a UART serial port is not enough, so UART serial port needs to be extended.
Up to now, there are more than 40 kinds of UART devices in the world. Most of them are based on the application of computer bus to UART, and their generality, pins and registers are rarely changed from 20 years ago. For embedded applications, the current UART devices have many weaknesses, such as complex operation, many pins and high price, which can not meet and adapt to the needs of embedded systems.
VK series UART devices
Aiming at the development trend of UART in embedded system, Viking company has designed and launched vk32xx series new multi bus interface UART devices
1. Support 8-bit parallel bus, SPI bus, UART and other host bus interfaces. At present, the 168 bit UART and 168 bit UART can be widely used in the products. Vk32 series 8-bit parallel bus interface UART products adopt the design of simplified control register, and reduce the chip pins through pin reuse. The simplified software design and PCB design are more suitable for embedded system requirements.
SPI interface bus series products are DSP and MCU with SPI interface to bridge and expand the synchronous SPI serial port to asynchronous UART serial port. Especially for the widely used DSP system, most DSPs only have synchronous serial port, which can only be used to communicate with peripherals with synchronous communication interface. Vk32 series SPI bus interface products can bridge / expand one SPI synchronous serial interface into 1-4 universal asynchronous serial ports, which is convenient to realize asynchronous serial communication between DSP and peripherals.
UART interface products innovatively expand a standard 3-wire UART into 2-4 enhanced UARTS. The UART extension protocol processing logic built in the chip can realize multiple independent configuration full duplex serial port expansion without other address signals and control signal lines, which provides a most concise solution for embedded systems that need to expand serial ports.
2. Support high-speed transmission. Each sub baud rate can be set independently. The maximum communication speed of sub serial port can reach 920kbps (5V working voltage). The maximum transmission rate of SPI bus supported by the host is 4Mbps, and the maximum transmission rate of 8-bit parallel bus of host is 10Mbps.
3. Wide operating voltage and low power design. Considering that the working voltage of the new DSP / FPGA in the embedded field is mostly 2.5V, while a large number of industrial control MCU still need to work under 5V voltage, the working voltage range of vk32 series UART is 2.5V ~ 5.5V. At the same time, the series of chips can work in automatic sleep and wake-up mode, effectively reducing power consumption.
4. Perfect FIFO function. Each channel has independent 16 stage receive and transmit FIFO, each FIFO has 4 programmable trigger point settings. The perfect FIFO function can buffer the sending / receiving data, reduce the operation of DSP / CPU on data transmission, improve the efficiency of CPU / DSP and the reliability of data transmission.
5. The sub serial channel has software or hardware automatic flow control to meet the needs of flow control in high-speed data transmission.
6. The sub serial port has programmable hardware RS-485 automatic control function and automatic 9-bit network address identification function, which greatly reduces the burden of processor, especially suitable for industrial RS-485 networking.
7. Each channel has independent and controllable data broadcast receiving function, which can be applied to the embedded system that needs data broadcast transmission and control.
8. All UARTS (including UART main interface and sub channel UART) support IrDA infrared communication.
Principle and block diagram of VK series UART devices
Vk3200 is the most functional model in vk32 series. Based on the schematic diagram of vk3200, this paper introduces the principle of UART chip of vk32 series. The internal structure of vk3200 includes host interface, sub channel, modem control logic and interrupt control logic. The host interface is the interface between vk3200 and CPU / DSP. By selecting the signal line in M1 and Mo mode, three interfaces, namely 8-bit parallel bus, SPI bus and UART, can be selected to connect with the host. The modem control logic is used to monitor and control the state signal line when connected with the modem; the interrupt control logic is used to generate and control various internal interrupts.
Clock generator provides clock for chip. Clksel lead can be used to select whether to obtain clock from crystal oscillator or external clock source. The subchannel logic part deals with data receiving and sending. The process of data transmission is: the host interface processes the data sent from the main port bus and then transmits it to the corresponding sub channel FIFO. After the data in the FIFO passes through the flow control logic, under the action of baud rate generator, the data is sent to the TX serial output signal line through the transmit shift register, and the received data is just the opposite. In the sub channel processing module, the control register is used to set each sub channel, the IR codec is used to encode and decode the infrared signal, and the sub channel flow controller is used for the automatic flow control when the sub channel transmits data. ［page］
Application in embedded system
The application fields of VK series UART devices in embedded products include: multi serial server / multi serial card, industrial / automatic field RS-485 control, wireless data transmission using CDMA / gprs modem, vehicle information platform / vehicle GPS positioning system, remote automatic meter reading (AMR) system, fiscal POS / bank terminal and other financial instruments, DSP data acquisition and transmission system, etc. The application examples are as follows:
1. The application of POS in tax control
Fiscal POS is a control intensive embedded system, which needs to control a large number of peripherals. Its basic configuration requires serial printer, modem, RS-485 network interface and fiscal IC card (asynchronous card) to work in UART based serial communication mode. At the same time, a large number of peripheral devices such as password keyboard, barcode scanner, barcode scale, contact IC card / contactless IC card reader, magnetic card reader, serial port display screen and other devices are connected with POS through RS-232 serial port.
By using vk32xx series UART devices, SPI / 8-bit parallel bus / UART can be selected to expand UART serial port flexibly according to the interface characteristics of MCU / CPU. Compared with the current scheme using GPIO to simulate the serial port, the scheme takes up less CPU I / O and resources, and even ordinary 8-bit MCU can be competent. At the same time, the expanded sub serial ports are standard hardware UART, which makes data transmission more reliable.
2. Application in remote automatic meter reading system
As shown in Figure 3, the remote automatic meter reading system consists of remote meter, centralized meter reading device and modem.
In the remote transmission table, one UART is extended to two UARTS by using VK3212 dual serial port expansion IC. The two uart1 and UART2 are connected with RS-485 / M-BUS interface and infrared interface respectively. The uart1 of VK3212 is set to RS-485 automatic receiving and sending and RS-485 network mode, which can automatically complete the data automatic receiving and sending and automatic network address identification of RS-485 / M-BUS without the control of MCU. The UART2 of VK3212 is set to infrared mode, which is used to connect the infrared setting window of remote transmission table.
In the centralized meter reading device, four sub serial ports UART are expanded by a 4-channel UART device vk3234 with SPI interface. MCU is connected with vk3234 through SPI bus. The UART of vk3234 is set to RS-485 automatic receiving and sending mode. The RS-485 / MBus transceiver controlled by UART of each sub-channel is connected with up to 250 remote transmission meters through RS-485 / M-BUS bus bus. Kv3234 can be based on a centralized meter reading device.
Because the serial port is extended by SPI interface, the serial port of MCU can connect PSTN / GSM modem to transmit the data to remote server.
3. Application in embedded vehicle information platform
The main interface of vk3233 can be selected from SPI and UART. The DSP / CPU in the embedded platform is connected with vk3233 through SPI / UART interface. The three sub serial ports extended from vk3233 are respectively connected with GPS module, reversing radar module and GSM / CDMA module, and modem control line is connected with GSM / CDMA modem. The whole embedded system shares a display device, which effectively saves the limited space in the car.
4. Application in serial server
In the field of industrial control, the external communication interface of many devices is still Low-speed serial port. In the future, the server will transfer data through serial port.
Figure 5 shows the circuit schematic diagram of an 8-port server (4 RS-232 serial ports and 4 RS485 serial ports). The parallel bit data lines of DSP / CPU in the embedded system connect two pieces of vk3266 to realize the expansion of eight serial ports. The address decoder controls the CS of two pieces of vk3266 to realize the chip selection control. In the above figure, vk3266 a connects four RS-232 transceivers, expanding four RS-232 serial ports with hardware flow control signals; vk3266b is connected with four RS-485 transceivers, setting vk3266 in rs-458 automatic receiving and sending control mode, and RTS signal is used to control the data transmission enabling de and data reading enabling Rd signal of RS-485 transceiver, so as to realize the automatic receiving and sending control of RS-485.
Selection reference and design suggestion
1. Selection reference
Vk32 series UART includes five product series, and the characteristics of each product series are as follows:
The main interface of vk321x series is UART. It is only connected with the host through Rx, TX and GND signal lines. Through the processing protocol inside the chip, one serial port is expanded to 2-4 full duplex serial ports which can work at the same time. In this mode, MCU operates UART devices in query mode. It should be noted in the design that the baud rate of the main interface should be greater than the sum of the baud rates of each sub serial port to ensure that all sub channels can communicate in full duplex mode at the same time. Vk321x is suitable for embedded products with low communication speed and simple design.
The main interface of vk322x series products is SPI synchronous transmission bus, and the maximum transmission speed is 4Mbps. It is suitable for MCU / DSP with SPI interface to extend asynchronous serial port. Most DSPs only have synchronous serial port. It can simplify the hardware scale of parallel bus expansion serial port and the software cost of simulating asynchronous serial port by SPI interface.
Vk323x series products have SPI and UART two optional main interfaces at the same time. The extended sub serial port has the function of hardware flow control and RS-485 automatic receiving and sending. It is especially suitable for RS-485 bus application which needs high reliable data transmission.
Vk325x is a UART device with 8-bit parallel bus interface, and vk326x is a UART device with three optional host interfaces. These two devices are used in applications that need to reduce the type of stock and require a large amount of data transmission.
2. Design suggestions
The interface design of asynchronous IC card. The asynchronous IC card conforming to 7816-3 is a half duplex asynchronous communication interface. In practical application, RX and TX of sub serial port can be connected directly with I / O signal of IC card after short circuit. For reliability, I / O signal of IC card can be driven by connecting 7407.
The design of modem interface. The current PSTN / GPRS / CDMA / GSM modem supports three line serial ports (TX, Rx, GND) to operate through at command. However, in practical application, it is easy to lose packets when only using three wire serial port, resulting in data retransmission and slow down the upload speed. It is recommended to use UART devices with modem interface in vk32 series, use DSR, DTR, RI and DCD to monitor modem status, and RTs and CTS to do flow control, so the speed can reach the highest.
The design of RS-485 bus. RS-485 is the most widely used half duplex communication system in industrial field. It is difficult to deal with some details when using MCU to control rx485 directly. When the system is reset, I / O may make the 485 transceiver in the sending state, which will cause the communication failure on the bus. In the data receiving and sending switching, the MCU I / O is usually controlled by the sending buffer state, and the last byte may still be there At the same time, when there is a large amount of data on the RS485 bus for transmission, MCU has to spend a lot of resources to determine whether the data is sent to the local machine, resulting in low efficiency. In view of these problems, it is suggested that users should choose devices with RS-485 automatic transceiver control and 9-bit network automatic identification when they need to use RS-485.
Vk32 series UART devices can work in the automatic RS-485 mode: when reset, RTS is in the receiving state, only when the data is sent, RTs works in the sending state, when the last bit of data is sent from the shift register, RTs automatically changes to the receiving state. At the same time, the UART of vk32 series supports the automatic identification of 9-bit network address. Only when the address on the RS-485 bus is consistent with the RS-485 network address set by UART, the interrupt will occur, which can free MCU from a large number of data processing unrelated to itself and improve the processing ability of the system.
Lead free is an irresistible trend in semiconductor industry. All vk32 UART products are packaged in lead-free way. In reflow soldering, it is necessary to pay attention to the welding temperature to meet the corresponding temperature requirements.
Editor in charge: GT