Analysis of Communication Module of Single Chip Computer Communication Module and PC

A multi-level control system can be established by combining a personal computer (PC) with multiple single-chip microcontrollers. Typically, the PC serves as the upper-level controller, while the minimal system of the microcontrollers acts as the lower-level unit. Communication between these units is usually implemented through two independent modules: a microcontroller communication module and a PC communication module.

The design of the single-chip communication module involves the serial port of the 8051 MCU, which features two physically separate data buffers—SBUF—with the same address (99H). This buffer is used for both sending and receiving data. The operation of the serial port and the baud rate are controlled by special registers SCON and PCON, while the timer functions as the baud rate generator.

Data transmission occurs when the CPU writes to SBUF, and data reception happens when the CPU reads from it. The serial port of the 8051 MCU supports full-duplex communication, meaning it can send and receive data simultaneously. The SCON register controls the working mode of the serial port.

Bits SM0 and SM1 in SCON determine the operating mode, as detailed in the table. SM2 allows for multi-machine communication in modes 2 and 3. REN enables serial reception, and TB8 represents the ninth bit of transmitted data in modes 2 and 3. RB8 holds the ninth bit of received data in modes 2 and 3 or the stop bit in mode 1 when SM2 is 0.

TI and RI are interrupt flags that indicate whether data has been sent or received. These flags are set automatically by hardware and cleared by software. Since the PC's RS-232 interface is managed by the 8250 chip, most PCs use 8-bit data communication. Therefore, the microcontroller should be configured in mode 1 for standard asynchronous communication.

In mode 1, the serial interface operates as an 8-bit asynchronous communication channel with a variable baud rate. Each data frame consists of 10 bits: one start bit (0), eight data bits, and one stop bit (1). When transmitting, the data is first stored in SBUF before being sent out via TxD. After transmission, the TI flag is set to 1.

During reception, data is received through RxD. Once the first 1-to-0 transition is detected, the receiver starts. After confirming the start bit, the receiver captures the full data frame. If RI is 0 or SM2 is 0, the stop bit is stored in RB8, and the RI flag is set to 1, indicating successful reception.

Baud rate settings depend on Timer 1, which must operate in mode 2 (auto-reload). In this mode, TL1 acts as an 8-bit counter, while TH1 holds the constant value. When TL1 overflows, the value from TH1 is copied back, allowing the timer to restart. This setup ensures a fixed frequency with a 1:1 duty cycle, enabling precise baud rate control based on the time constant.

For example, with an oscillator frequency (fosc) of 6 MHz, setting the baud rate to 1200 requires TH1 and TL1 to be set to OF3H. The communication line typically uses a standard twisted pair cable, with a maximum distance of about 30 meters. For longer distances, optical isolation or current loop interfaces are recommended, extending the range up to 1000 meters. At lower baud rates like 300, the communication is more stable, and no special cabling is needed.

Ceramic parts

Ceramic Parts,Advanced 95 Ceramic Materials,High Strength Ceramics,Durable Ceramic Components

Yixing Guanming Special Ceramic Technology Co., Ltd , https://www.guanmingceramic.com