1 Introduction
This article introduces a single-chip multi-machine
parallel communication system, using 89C51 as the host and multiple 89C2051 as slaves. (89C2051 is a 20-pin 300MIL package with 2K FLASH E2PROM. Except for the lack of two parallel ports, it has all the functions of the MCS-51 series of single-chip microcomputers. Because of its small size and powerful functions, it will be widely used in the field of single-chip microcomputer applications). This parallel communication method is suitable for acting as a communication controller in multi-site, multi-level detection and control systems; it is also suitable for use as a single-chip microcomputer serial port expansion circuit.
Figure 1 Chip logic diagram and four working states
Figure 2 MCU parallel communication principle block diagram [page]
In a multi-machine parallel communication system composed of a single chip, information exchange on the bus generally adopts methods such as PIO (parallel interface) and dual-port registers, and is assisted by a bus arbitration circuit. Commonly used parallel interface chips include 8155, 8255, etc. This article introduces a simple parallel interface circuit, which can not only replace chips such as 8255, but also make the circuit structure simpler and more compact. The circuit consists of a 74HC74 and a 74HC646 (300MIL narrow package).
74HC646 is a three-state bus buffer register, which is actually a dual-port shared memory, but the shared storage area is very small, with only one data input register and one data output register. It is used as a temporary transfer station for single-byte communication data. Every time a byte is transmitted, the master and slave machines shake hands once, take the data away, and then continue the communication of the next byte. 74HC646 can latch the data of the two buses separately, and then exchange data through the internal bus of the chip.
74HC646 has four working states. By controlling these four working states, multiple microcontrollers can use the data port to exchange data, saving the remaining port lines for other work, such as driving LEDs, controlling switches, etc.
The logic diagram of the 74HC646 chip and its four working states are shown in Figure 1.
3 Principle of parallel communication of single-chip microcomputers
The latching of data by 74HC646 only prepares information for completing data exchange. The realization of communication between multiple microcontrollers must also have communication means to enable the microcontroller to understand the working state on the bus and avoid bus conflicts. Four-wire handshake communication is used here: two lines are sent from the sender to the receiver to notify the receiver that the data is ready (TFNE*, RFNE* in Figure 2); two lines are sent from the receiver to the sender to notify the sender that the data has been received (TFNF*, RFNF* in Figure 2). The communication signal is generated by the 74HC74 circuit. The block diagram of the principle of parallel communication of single-chip microcomputers is shown in Figure 2.
4 Multi-machine parallel communication protocol
The parallel communication microcontroller above does not have a blocking circuit to prevent the master and slave from writing or reading numbers to the 74HC646 at the same time. Therefore, each single machine must control its next operation according to the status information during bidirectional transmission, that is, to communicate. Only by coordinating the software and hardware communication protocols can errors be avoided and competition conflicts with the 74HC646 will not occur. Therefore, in addition to the communication circuit mentioned above, the following protocol must be followed when compiling the software:
When the host sends data to the 74HC646, the 74HC646 receiving register must be empty.
The data transmission between the host and the slave must pass through the 74HC646. The protocol does not allow both parties to operate the 74HC646 at the same time, and their operations must be controlled according to the status information.
5 Communication protocol format and execution process
5.1 Information format
In the asynchronous communication transmission of parallel communication, there are also frame type and format issues. A frame format similar to serial communication can be used:
feature word
length
data 1
data 2
...
check code
[page]
5.2 Execution process of communication protocolThe following is an example of the execution process of the communication protocol using the detection method.
5.2.1 The process of the host writing data to the slave: (host writes, slave reads)
The host writes data to the 74HC646, then notifies the slave that there is data, and the slave reads data from the 74HC646.
① The host reads the status bit and detects whether the TFNF* bit is zero.
② If TFNF*=1, the host waits temporarily; if TFNF*=0, the host writes data to the 74HC646, making TFNF*=1, and TFNE*=0 at the same time.
③ The slave reads the status bit and detects whether the TFNE* bit is zero. If TFNE*=1, the slave waits temporarily; if TFNE*=0, the slave reads data from the 74HC646, making TFNE*=1, and TFNF*=0 at the same time.
④ The host detects whether the status bit TFNF* is zero again. If it is "0", it means that the slave has taken the data from 74HC646, and the host can send the next data.
5.2.2 The process of the host reading the slave: (slave writes, host reads)
The slave writes data to 74HC646, and then notifies the host that there is data. After receiving the signal, the host takes the data from 74HC646.
① The slave reads the status bit and detects whether the RFNF* bit is zero.
② If RFNF*=1, the slave waits temporarily; if RFNF*=0, the slave writes data to 74HC646, making RFNF*=1, and making RFNE*=0 at the same time.
③ The host reads the status bit and detects whether the RFNE* bit is zero. If RFNE*=1, the host waits temporarily; if RFNE*=0, the host reads data from 74HC646, making RFNE*=1, and making RFNF*=0 at the same time.
④ The slave detects again whether the status bit RFNF* is zero. If it is "0", it means that the slave has taken the data from 74HC646 and the host can send the next data.
6 Flowchart (Detection Method)
The program flow using the detection method is shown in Figure 3.
Figure 3 Flowchart of the program using the detection method
If the interrupt method is used, only slight modifications need to be made to the execution process and the flowchart.
Previous article:Design and analysis of reset circuit system based on MSP430 series microcontroller
Next article:Design of AC digital voltmeter based on MSP430F448 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
- A rather strange op amp, take a look
- Undergraduate entrance examination
- Bill of Materials Problem
- Direct Memory Access (DMA) Controller - TMS320VC5509A
- A must-read for beginners! Experts explain the PCB return path for high-speed circuits
- Two major power outages in five days! The Taiwan authorities have asked TSMC to relocate or suspend some production lines
- PADS PCB 3D component library
- Frequency division of analog signals
- C2000-GNAG Operation and Use
- [ESK32-360 Review] 6. Hello! Hello! Hello! Hello!