1 Overview
In recent years, intelligent modules with complete measurement or control functions have emerged continuously, and such modules need to
communicate with the host microcontroller or microcomputer through RS-232S or RS-485 serial ports to form a hierarchical distributed measurement and control system. However, most microcontrollers at this stage have only one UART serial port, which is difficult to meet the requirements of communicating with both intelligent modules and host microcomputers. Looking at the existing serial port expansion solutions, there are disadvantages such as more software and hardware resources of the microcontroller, complicated programming, fewer serial port expansions, complex hardware circuits and high costs. The use of UART multi-serial port expander SP2337 can well solve the expansion problem of multiple serial ports of the microcontroller.
2SP2337 main features and pin functions
SP2337 is a UART multi-serial port expander designed with low-power CMOS technology. This device can expand a high-baud rate UART serial port into three higher-baud rate UART serial ports, thus providing a good solution for systems that need multiple serial ports. The main features of this device are: it
can
expand one UART serial port into three UART serial ports;
full-duplex asynchronous operation,
all four UART serial ports are full-duplex asynchronous operation mode;
high working speed, up to
1200b/s~9600b/s (any non-standard baud rate can be set by the crystal oscillator frequency);
simple baud rate setting, only need to change the input clock frequency;
small baud rate error, the data output baud rate error of each serial port is less than
0.25%;
wide receiving baud rate range, requiring each serial port data baud rate to be less than
2.5%;
extremely low data transmission bit error rate, less than
10-9 (received data baud rate error is less than 2%);
with power saving mode, after entering the power saving mode, the typical quiescent current is
0.5μA;
It can automatically wake up when data appears at the receiving end of any serial port;
wide operating power supply voltage (
2.4V~5.5V);
low operating current, typical operating current is
4.4mA.
The device has
multiple packaging forms such as DIP, SOIC and SSOP. The pin arrangement is shown in Figure 1. The pin functions are shown in Table 1.
3 Application Technology
There are many principles to follow
when using
SP2337.
SP2337 is suitable for applications where serial data is 7 bits.
Serial port
0-serial port 2 are three serial ports with higher baud rates (sub-serial ports).
Serial port
3 is a high baud rate serial port (mother serial port), and its data transmission rate is 4 times that of the sub-serial port. For example, when the input clock frequency fos,cin is 10MHz, the baud rate of serial port 3 is 19200b/s. The baud rate of serial port 0-2 is 19200b/s/4=4800b/s; if you need to obtain the baud rate K on serial port 0-serial port 2, you need to change the clock frequency according to the following formula.
ADRI1 and ADRI0 are the downstream address lines. When ADRI1ADRI0=00, 01, 10, they correspond to sub-serial ports 0, 1, 2 respectively. When ADR1ADR0=11, it is the address of serial port 3, and it is also the command/data port address of SP2337.
ADRO1 and ADRO0 are the serial port address lines for uplink data. When ADRO1ADRO0=00, 01, and 10, they correspond to sub-serial ports 0, 1, and 2 respectively. When the UART of the host computer receives data sent by serial port 3, it immediately reads the status of address lines ADRO1 and ADRO0, and determines which serial port the data is sent from based on the status of ADRO1 and ADRO0.
The wake-up condition is to
write a byte of data to any data receiving port of serial port 0-serial port 3. Since the wake-up time of SP2337 is about 25ms, the data used for chip wake-up will not be received correctly. Therefore, the following chip wake-up process should be adopted: first send a byte of data to wake up the chip, and then send valid data after a delay of 25ms.
In order to quickly and reliably transmit bulk data, the following method can be used to achieve fast and reliable data reception and transmission.
If the host computer only needs to send data to one serial port, it can send one byte of data to the serial port, and then
send four bytes of "0X00" to address 11 (the address of serial port 3), and then send one byte of data to the serial port that needs to send data. Then send four bytes of "0X00" to serial port 3, and send them in this way in a loop. [page]
If the host computer needs to send two data blocks to two serial ports respectively, it can send one byte of data to the two corresponding sub-serial ports respectively, and then
send four bytes of "0X00" to serial port 3, and then send the next byte of the two data blocks to the two sub-serial ports respectively.
If the host computer has three data blocks that need to be sent to three sub-serial ports respectively, it can first send one byte of valid data to each of the three sub-serial ports, and then
send two bytes of "0X00" to serial port 3, and then send valid data to the three sub-serial ports in a loop.
Note that
the data written to serial port 3 for delay can only be "0X00". If other data is written, unpredictable results will occur.
The data transmission process of SP2337 is as follows: If the host computer needs to send data "0X28" from serial port 2, it needs to set ADRI1 to "1" and ADRI0 to "0" first, and then send the data "0X28" to serial port 3 through the UART port of the host computer.
SP2337 has only two executable commands, namely reset and sleep commands. When the host computer writes data "0X35" or "0XB5" through serial port 3 (address "11"), the chip performs a software reset, and the reset time is about 21.75ms. When the written data is "0X55" or "0XD5", the chip enters the sleep state.
4 Specific Applications
SP2337 can be
used
to expand a microcontroller with only one UART serial port to a microcontroller with three UART serial ports. The following takes the commonly used AT89C51 microcontroller as an example to give the corresponding serial port expansion circuit, as shown in Figure 2.
In Figure
2, the UART port of AT89C51 is connected to the serial port 3 of SP2337. Serial port 3 also serves as the command/data port. ADRI1 and ADRI0 are connected to the P2.3 and P2.2 lines of AT89C51, which are used to select the corresponding serial ports 0-2 when sending data. ADRO1 and ADRO0 are connected to the P2.1 and P2.0 lines of AT89C51, which are used to determine which serial port 0-2 the received data comes from. The clock frequency of SP2337 is selected as 20MHz. At this time, the baud rate of serial port 3 is 19200b/s, and the baud rate of serial port 0-2 is 9600b/s. The communication program supporting the above circuit is given below. The program is compiled in C51.
#include
[page]
5 Conclusion
SP2337 multi-serial port expander can be widely used in industrial control, data acquisition, instrumentation, smart home appliances, computer RS232 port expansion, wired and wireless data transmission and other fields. The multi-serial port circuit composed of this device has the characteristics of low hardware cost, high cost performance, high working speed, simple baud rate setting, etc. It is a good solution for multi-serial port application system.
Previous article:Automatic calibration and adjustment of calendar clock in single chip microcomputer system
Next article:A method for measuring engine speed and acceleration time based on single chip microcomputer
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- SSD1306 Chinese character mobile demonstration
- Using Low Noise Modules in Satellite Applications
- Some misunderstandings in FPGA learning.zip
- MSP430F5438A supports communication scheme verification based on COAP protocol
- I want to design a sine wave generator.
- [RT-Thread reading notes] Part 1 Simple principles of the kernel
- I worked hard to drive the CC2640 Hanshuo electronic tag.
- Solution to the error empty character constant
- Newbie wants to use PLC to control air conditioner
- Looking for a microcontroller model