The serial port is the most commonly used and simplest interface in embedded devices. How to expand the serial port of the CPU is of great significance for multi-functional embedded devices. SC16IS752 is a conversion chip with I2C/SPI bus interface to dual-channel UART launched by NXP. It can provide a rate of up to 5Mbit/s and is compatible with the widely used 16C450, which is conducive to software transplantation and writing. The microcontroller in this article uses the LPC2214 launched by NXP, based on the 16/32-bit ARM7TDMI-STM core, 144-pin package, and extremely low power consumption, which is particularly suitable for industrial control.
The main features of SC16IS752 are as follows:
●Operating voltage: 3.3 or 2.5V, operating temperature range: -40~+85°C, low power consumption, sleep current of 3.3V is less than 30uA;
●Two full-duplex UARTs, 64-byte FIFO, fully programmable character format, RTS/CTS automatic flow control;
●Small package, easy to connect to CPU, available in HVQFN32 and TSSOP28 packages.
This article uses SPI to expand the CPU serial port, and SC16IS752 is set to slave mode. The following introduces its hardware characteristics.
1. Pin functions and registers of SC16IS752
Figure 1 shows the pinout of the SC16IS752, and Table 1 shows the functions of each pin.
Figure 1 Pin Diagram
Table 1: SPI interface pin functions
Pins |
Function |
Pins |
Function |
Pins |
Function |
1 |
Channel A Request to Send |
11 |
SPI data input pin |
twenty one |
I/O or modem RIB |
2 |
Channel A Clear to Send |
12 |
SPI data output pin |
twenty two |
land |
3 |
Channel A Send Output |
13 |
SPI input clock |
twenty three |
Channel B Send Output |
4 |
Channel A accepts input |
14 |
Idle connected to VDD |
twenty four |
Channel B accepts input |
5 |
Hardware Reset |
15 |
Interrupt |
25 |
I/O or modem DSRA |
6 |
Crystal input |
16 |
Channel B Clear to Send |
26 |
I/O or modem DTRA |
7 |
Crystal output |
17 |
Channel B Request to Send |
27 |
I/O or modem CDA |
8 |
Supply voltage |
18 |
DSRB for I/O or modem |
28 |
I/O or modem RIA |
9 |
SPI interface selection |
19 |
I/O or modem DTRB |
|
|
10 |
SPI chip select |
20 |
I/O or modem CDB |
|
|
The registers mainly include the transmit register (THR), receive register (RHR), control register (FCR), line control register (LCR), status register (MCR), MODEM status register (MSR), interrupt enable register (IER), interrupt identification register (IIR), divisor register (DLH/DLL), transmit control register (TCR), trigger point register (TLR), I/O pin control register, etc. [page]
2. SPI timing diagram in SC16IS752
As shown in the following figure:
3. SC16IS752 and LPC2214 interface circuit diagram
Figure 4 is a partial circuit diagram of the extended serial port. The 3-wire serial port connection method is used, and the SC16IS752 is powered by a 3.3V power supply. The chip package is TSSOP28, the crystal is 1.8432MHZ, and the oscillation circuit is composed of C3 and C4. The SC16IS752 hardware uses a resistor-capacitor reset, which is composed of R3 and C2. It can also be reset by the I/O port of the microprocessor. The author has tested both methods in practice. This article uses a resistor-capacitor reset, which can save I/O ports. The pin 15 of the SC16IS752 is connected to the INT3 of the LPC2214. In this way, the software can be written in an interrupt mode or in a scanning mode. R4 is a pull-up resistor to ensure reliable level. The SPI1 of the CPU is the main mode, and an I/O is connected to the SELL1 of the SC16IS752. It should be noted that the 60th pin SELL1 of the LPC2214 must be connected to a high level, and R5 is used as a pull-up resistor. R1 and R2 are set for the internal FLASH startup of LPC2214. Pay special attention to the use of the CPU's P0.14 pin. The FLASH boot loader code is executed when the CPU is powered on or reset. When the device is reset, when P0.14 is low, ISP is started and software changes are made. When the ISP function is not needed, connect the pull-up resistor R6 to keep P0.14 in a stable state. CPU reset is not given due to space limitations.
Figure 4 SC16IS752 and LPC2214 interface circuit diagram
4. Level conversion
The level conversion uses the SP3232E chip of SIPEX, which meets the EIA/TIA-232-standard. The operating voltage is +3.0V~5.5V. In addition, the pins provide ESD protection. The pins of the driver and receiver can withstand ±15KV human body discharge mode and IEC1000-4-2 air gap discharge mode. As shown in the following figure:
Figure 5 Level conversion
5. Initialize registers
The procedure for initializing the registers of SC16IS752 is as follows:
/*SC16IS752 initialization*/
void init_is752(void) {
/*Initialize the first serial port A of SC16IS752.*/
write_is752_rega(IS752_CH_A,IS752_LCR,0xbf); write_is752_rega(IS752_CH_A,IS752_EFR,IS752_EFR_VAL);
write_is752_rega(IS752_CH_A,IS752_LCR,0x00);
/*Set SC16IS752 serial port A interrupt.*/
write_is752_rega(IS752_CH_A, IS752_IER, IS752_IER_VAL);
write_is752_rega(IS752_CH_A, IS752_FCR, IS752_FCR_VAL);
write_is752_rega(IS752_CH_A, IS752_MCR, IS752_MCR_VAL);
write_is752_rega(IS752_CH_A, IS752_EFCR, IS752_EFCR_VAL);
/* Initialize the second serial port B of SC16IS752, same as serial port A, omitted. Clear register program, omitted*/
}[page]
/* Write data */
void write_is752_rega(unsigned char chx, unsigned char addr, unsigned char data){
unsigned char temp;
if((IS752_CH_A == chx) ||(IS752_CH_B == chx)){
CLR_IS752_CS;
temp = addr<<3;
temp |= chx;
spi_send_byte(SPI1,tmp);
spi_send_byte(SPI1,data); /*Send data.*/
SET_IS752_CS;
}
}
/*Read data*/
unsigned char read_is752_rega(unsigned char chx, unsigned char addr){
unsigned char temp;
if((IS752_CH_A == chx) ||(IS752_CH_B == chx)){
CLR_IS752_CS;
temp = addr<<3;
temp |= 0x80|chx;
spi_send_byte(SPI1,temp);
spi_send_byte(SPI1,0xff);
SET_IS752_CS;
return(S1SPDR);
}
}
The SPI programming interface is described in detail in other books and will not be described here (see Reference 1).
5. Conclusion
There are many serial port expansion chips on the market. We have used parallel ports to expand serial ports before, such as 16C552, 16C554, etc. Compared with them, SC16IS752 has simple connection, low power consumption, small size, and good stability in practical applications. It has been used in our designed products. At the same time, it has a small size and low power consumption, and will have broad application prospects in handheld devices.
The author's innovations: 1. Only five CPU lines are needed to expand two serial ports, saving CPU resources;
2. Small size, low power consumption, and broad application prospects in handheld devices;
3. Simple connection and good stability.
Figure 6 Size comparison of SC16IS752 and surrounding devices
References
1. Zhou Ligong et al. ARM Embedded System Basic Tutorial. Beijing: Beijing University of Aeronautics and Astronautics Press. 2005www
2. NXP SC16IS752 /SC15IS762 datasheet. Rev0.12-19 September 2005
3. Li Chunguang et al. Design and implementation of interface between embedded microprocessor and FLASH flash memory, Microcomputer Information, (2006) 07-2-0154-04
Previous article:Implementation of high-speed device driver based on embedded Linux system
Next article:Research on image acquisition method based on S3C44B0 development board
Recommended ReadingLatest update time:2024-11-16 23:56
- Popular Resources
- Popular amplifiers
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
- Chuanglong Technology Allwinner A40i Development Board Review 3 Installation of Linux SDK and Lessons Learned
- What are the two chips with silkscreen SI4GK and S551J?
- Problems with sensor acquisition circuits
- What are the RF challenges of small cells for 5G networks?
- Is there really no threshold to making cars?
- Why not use plastic rope as wire?
- [MM32 eMiniBoard Review] AD detects thermistor value to achieve serial port temperature printing LED temperature warning
- About ESP32's off-chip RAM configuration. Go to esp-idf official reference
- Flashing Linux firmware for RK3399 development board (Part 2)
- Basic Features of DSP TMS320C6000