The MCU CPU communicates with external devices through three main methods: unconditional transfer, polling (query) transfer, and interrupt transfer. To illustrate these methods, we will use the example of a microcontroller interfacing with a micro printer. Suppose the user wants to print three pieces of data stored in memory addresses 10H, 11H, and 12H of the microcontroller. The 8051 microcontroller uses its parallel port P2 to communicate with the parallel data port DB of the printer.
(1) Unconditional Transfer Method
In this mode, there is no handshake or status check between the CPU and the peripheral device. The CPU assumes the printer is always ready to receive data. This method is simple—only the instruction to send data to P2 is needed. However, it has a major drawback: data can be lost because the CPU operates much faster than the printer. If the printer isn’t ready, the CPU may send multiple data bytes before the printer can process them, leading to errors.
(2) Polling (Query) Transfer Method
This method, also known as conditional transfer, involves the CPU checking the status of the peripheral device before sending data. For output operations, the CPU must ensure that the peripheral is ready to accept new data. This is typically done by reading a "ready" signal from the device. A single bit, often represented by a D flip-flop, can indicate whether the device is ready (Q=1) or not (Q=0). In our example, the printer has a BUSY pin. Before printing, the printer sets this pin high, and after processing, it goes low. The microcontroller checks this pin before sending each byte. If the BUSY pin is high, the CPU keeps polling until it becomes low, then sends the data. This ensures reliable communication but requires the CPU to wait, reducing efficiency, especially when transferring large amounts of data.
(3) Interrupt Transfer Method
To address the inefficiency of polling, the MCU uses the interrupt method. In this approach, the CPU continues executing other tasks while waiting for the peripheral to be ready. When the peripheral is ready, it sends an interrupt signal to the CPU, which pauses its current task, processes the interrupt, and then resumes where it left off. This method significantly improves CPU utilization, as the CPU doesn't waste time waiting. The interrupt system consists of hardware and software components that manage these events, allowing for more efficient and responsive communication between the CPU and peripherals.
T04 Series Terminal Blocks
Withstand high voltage up to 750V (IEC/EN standard)
UL 94V-2 or UL 94V-0 flame retardant housing
Anti-falling screw
Optional wire protection
1~12 poles, dividable as requested
Maximum wiring capacity of 4 mm2
4 mm² Terminal Blocks,high quality terminal strips,BELEKS T04 series terminal connectors,3 amp connector strips
Jiangmen Krealux Electrical Appliances Co.,Ltd. , https://www.krealux-online.com