Analysis of three data transmission methods for exchanging information of external devices based on 8051 single chip microcomputer

The MCU CPU exchanges information with external devices in the following ways: unconditional transfer mode, query transfer mode and interrupt transfer mode. We use the microcontroller and micro printer interface as an example to describe these three methods. Assume that the user wants to print three data, which are stored in the internal data memories 10H, 11H, and 12H of the microcontroller, and the 8051 uses the parallel port P2 to exchange data with the parallel data port DB of the micro printer.

(1) Unconditional transmission method

There is no contact signal in this data transfer mode, that is, the CPU always thinks that the printer is in a "ready" state at all times. In this transmission mode, only the instructions for sending data to P2 in the program need to be added, and data transmission can be realized. However, this data transmission method has a fatal weakness, and the data is easy to lose. This is because the speed of the CPU is quite fast, and the speed of the printer is relatively slow. The result is that the CPU has sent the time when the printer prints a data. Multiple data.

(2) Query transmission method

The query transmission is also called conditional transmission. In this transmission method, whether it is input or output, the computer is the active party. For the correctness of data transfer, the computer must first check whether the external device is in the "ready" state before transmitting the data; for the output operation, it is necessary to know whether the peripheral has processed the data output by the last computer. Only by querying that the peripheral is in a "ready" state can the computer issue an instruction to access the peripheral to exchange data. The status information generally only requires one binary code to indicate "ready" and "not ready". Therefore, only one D flip-flop can be used to save and generate status information in the interface. For example, “Ready” has a D flip-flop Q=1; “Not Ready” is represented by Q=0. Query mode process: Query, ie read “Ready” pin, if the pin is “Ready” The status is data transfer. If the pin is "not ready", continue to query until the pin is "ready" and then transfer data.

In our example, you can add a pin named BUSY to the printer. Before the printer starts printing a data, make the pin high. After printing a data, make the pin low. The initialization of the foot is 0. We connect this pin to the pin INT0 of the microcontroller. Before sending a data, the MCU will check whether the pin status is 0. If it is 0, it will send data. Otherwise, continue the query until the pin is 0, then send the data, see the example:

The BUSY pin of the printer is 0 after power-on.

The MCU runs the first instruction and sets the starting point of the print buffer.

The microcontroller runs the second instruction and sets the print byte.

The MCU runs the third instruction and reads the status of the BUSY pin of the printer to determine whether the status is 0. If it is 0, the first data is sent, and the printer sets the BUSY pin to 0 to start printing.

The microcontroller runs the next instruction, and the print buffer is incremented by one to enable the second data to be sent the next time. Determine whether the data has been sent, not finished, ready to send the next data, read the state of the printer pin BUSY.

The BUSY state of the pin is 1, and the query continues.

The BUSY state of the pin is 0, the second data is sent, and the print buffer is incremented by 1, so that the third data can be sent next time, and it is judged whether the data has been sent, not sent, ready to send the next data, and the print buffer is added. 1. Determine if the data has been sent. The three data are sent and the program ends.

It can be seen that the disadvantage of this method is that there is a waiting process, especially when the data is continuously transmitted. Since the peripheral works much faster than the CPU, the CPU has to wait a long time after completing a data transfer. Time can be used for the next transfer. During the waiting process, the CPU cannot perform other operations, so the efficiency is relatively low, and an effective way to improve CPU efficiency is to use the interrupt mode.

(3) Interrupt mode

As we mentioned earlier, the unconditional transmission method is not reliable, and the query transmission method wastes CPU time too much.

In order to solve this problem, the MCU sets another transfer method - the interrupt mode. The so-called interrupt means that when the CPU of the CPU is processing something, an external event occurs and the CPU is requested to process it quickly. Therefore, the CPU temporarily interrupts the current work and transfers to the event that occurred during the processing; after the interrupt service is processed Then go back to the place where it was interrupted and continue the original work. This process is called interruption. The part that implements this function is called the interrupt system, and the source of the request to generate the interrupt is called the interrupt source.

Tablet PC Pad


A tablet computer is an electronic device that integrates mobile commerce, mobile communication and mobile entertainment, with a touch recognition LCD screen, handwriting recognition and wireless network communication functions. At present, the tablet computer has become the most popular electronic product.

1.In appearance, the tablet computer looks like a large-screen mobile phone, or more like a separate LCD screen.

2.In terms of hardware configuration, a tablet computer has all the hardware devices of a traditional computer, and has its own unique operating system, compatible with a variety of applications, and has a complete set of computer functions.

3.Tablet PC is a kind of miniaturized computer. Compared with traditional desktop computers, tablet computers are mobile and flexible. Compared with notebook computers, tablet computers are more compact and more portable.

4.Tablet PC is a digital notebook with digital ink function. In daily use, you can use the tablet computer like an ordinary notebook, take notes anytime and anywhere, and leave your own notes in electronic texts and documents.


Tablet Pc Pad,Mobile Tablet,Scratch Pad Tablet Pc,Tablet Pc,Tablets & Presentation Equipment,Educational Tablet

Jingjiang Gisen Technology Co.,Ltd , https://www.gisengroup.com