1 Baud rate conversion circuit
The baud rate conversion circuit is shown in Figure 2. The circuit uses two microcontrollers 89C5l as the core of the circuit, and uses the UART serial port of the microcontroller to communicate with related equipment. Microcontroller u1_L. (Connecting to a device with a low baud rate) communicates with a device with a baud rate of 115.2 kbps, and microcontroller U2_H (connecting with a device with a high baud rate) communicates with a device with a baud rate of 172.8 kbps. Ul_I, the communication with U2_H adopts parallel port mode to speed up Ul_I. The rate of data transfer with U2_H. The communication between U1_L and U2_H can use interrupt query or handshake query for data transfer.
The circuit uses two 75176 interface driver chips to form an RS-422 communication interface. The communication interface composed of U3 and U4 is connected to the 115.2 kbps device, and the communication interface composed of U5 and U6 is connected to the 172.8 kbps device. The communication interface uses interrupt technology. The baud rate converter works as follows: U1_I. After receiving the data from the device from the serial port, it outputs the data from the Pl port and notifies U2_H to get the number. After U2_H gets the data, it sends the data to the device and notifies Ul_I at the same time. The data has been taken away to prepare for the next output data of U1-L. When U2_H receives the data from the device from the serial port, it queries U1_I to see if it is allowed to receive data. If it is allowed to receive data, U2_H outputs the data from the P1 port and notifies Ul_L to get the data. After getting the data, Ul_L sends the data to the device. At the same time Notify U2_H that the data has been taken away to prepare for U2_H's next data output; if Ul_L is not allowed to receive data, U2_H will postpone sending the data.
2 Application of baud rate converter
In applications, baud rate converters can be divided into one-way transmission and two-way transmission according to usage. Data transfer between two microcontrollers can use interrupt mode. Query mode can also be used. If the query mode is used, several bits of the P2 port are used as query signals during programming to achieve one-way or two-way transmission.
2.1 One-way transmission
One-way transmission means that the data flow of the communication port only goes in one direction, that is, the data received from Ul_L is sent from U2_H, or the data received from U2_H is sent from Ul_L. Software programming is relatively simple this way. Now take U1_L only to receive data from external devices, and U2_H to only send data to external devices, using the query method as an example. The flow chart of data transmission between the two microcontrollers is shown in Figure 3. Among them, P2.2 of Ul_L is used as a query signal to transmit new data to U2_H (P2.5 of U2_H). P2.2=“0” means there is new data, and P2.2=“1” means there is no new data; U2_H P2.2 is used as the query signal for receiving U1_L data (P2.5 of U1_L). P2.2=“O” means that new data can be received, and P2.2=“1” means that new data cannot be received. If the interrupt mode is used, the query signals of the two microcontrollers are simpler. As long as Ul_L queries U2_H whether it can receive the data signal, U2_H does not need to query the query signal of U1_L.
2.2 Bidirectional transmission
Bidirectional transmission means that the communication port can receive data and send data at the same time. The data flow is bidirectional. Ul_L and U2_H both receive and send data. Software programming in this way is more complicated, especially when querying is used to transmit data in both directions. The query signals between microcontrollers are even more complicated. Taking the two-way query mode as an example, the flow chart of data transmission between two microcontrollers is shown in Figure 4. The process of U2_H is the same as that of U1_L. The query signal when U1_L transmits data to U2_H is the same as the definition of one-way transmission. P2.3 of U2_H is used as the query signal to transmit new data to U1_L (P2.4 of U1_L). P2.3 = "0" means there is new data. data, P2.3=“l” means there is no new data; P2.3 of Ul_L is used as a query signal to receive U2_H data (P2.4 of U2_H), P2.3=“O” means new data can be received, P2.3=“1” means that new data cannot be received. If interrupt mode is adopted, query signals can be reduced and programming can be simplified.
2.3 Precautions when applying
If the handshake mode between two microcontrollers uses interrupts, since U2_H sends data to the outside faster than U1_L receives external data, when Ul_L transmits data to U2_H, there is no need to consider the status of U2_H, and when U2_H transmits data to U1_L, since U2_H receives external data Data is sent to the outside faster than U1_L. U2_H must query the status of Ul_L, that is, whether U1_L is in the state of receiving U2_H data. Otherwise, U2_H cannot transmit data to Ul_L.
If it is used as an RS_485 communication interface, you only need to make slight changes to the circuit in Figure 2 to add read and write control to the 75176 chip. At the same time, the single-chip computer connected to the main communication device among the two microcontrollers serves as the host, through a bit of the P2 port. Coordinate whether the two microcontrollers receive data or send data.
It is worth noting that this baud rate converter will be subject to certain restrictions in different applications. When using it, you should pay attention to the following points: ① When the baud rate is very high, you must consider whether the serial port of the microcontroller can be realized; ② When converting from a high baud rate to a low baud rate, you must consider whether the microcontroller with a low baud rate can send data without losing data; ③ When converting in both directions, you must consider both the above situation and the size of the program. , as well as the impact of execution time on bidirectional data transmission, calculate whether two microcontrollers can achieve transformation without losing data, and leave a margin in time; ④ When querying, pay attention to the relationship between handshake signals, and do not generate errors for the same data Read repeatedly, so that the data is repeated; ⑤ When the baud rate is different, the microcontroller can choose different crystal oscillator frequencies.
2.4 Examples and source programs
In actual use, if the situation shown in Figure 1 is encountered, a baud rate converter is required to convert the communication data with a baud rate of 172.8kbps into a baud rate of 115.2kbps, and then transmit it to the upper computer. The actual circuit used is shown in Figure 2. In this example, in order to prevent data from being lost due to receiving data faster than sending at a certain time, 8 data areas are added to the U2_H microcontroller program as receiving data storage buffers.
3 Conclusion
Through long-term communication experiments and practical applications, the designed baud rate converter solution is feasible, the communication is reliable, and there is no data loss. In some systems, due to the special communication baud rate, when there is a baud rate mismatch between devices, communication between devices with different baud rates can be achieved through a baud rate converter. By changing the crystal frequency of the microcontroller, conversion of various baud rates (within the range allowed by the microcontroller) can be met.
Previous article:Application of microcontroller in baud rate converter
Next article:Application of microcontroller in baud rate converter
- Popular Resources
- Popular amplifiers
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- Detailed explanation of big data technology system: principles, architecture and practice (Dong Xicheng)
- Handbook of Multisensor Data Fusion: Theory and Practice
- Multi-Sensor Data Fusion: An Introduction
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
- Introduction to MSP430 development tools (JTAG SBW BS)
- There is nothing that cannot be embedded, only imagination can be used. Popular Science of Embedded Systems
- Partial Discharge in Switching Power Supplies
- The experiment got me all greasy:lol
- EEWORLD University Hall----Live Replay: Supporting 'Dual Carbon' - ADI Smart Factory Solution
- Multi-clock design strategy for FPGA in large-scale design.pdf
- [Mil MYD-YA15XC-T Review] + Unboxing and Power-on Test
- The first case in China! A 72-year-old high-level paraplegic patient eats fried dough sticks and plays mahjong with his mind. Zhejiang University's brain-computer interface has achieved many firsts
- I made a website to download Keil, Cube and other resources. Does anyone want to try it? It's free and has no speed limit.
- Does leaving the charger plugged into the socket consume electricity?