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

A personal computer (PC) and multiple single-chip microcontrollers can form a multi-level control system. Typically, the PC serves as the higher-level controller, while the minimum system of multiple MCUs acts as the lower-level controller. The communication between these components is usually implemented through two independent modules: one for communication with the microcontroller and another for communication with the PC.

Design of the Single-Chip Communication Module

The serial port of the 8051 MCU has two physically separate data buffers, SBUF, but they share 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. The timer functions as a baud rate generator, ensuring proper timing for data transmission.

The CPU writes data to be sent into the SBUF, and reads received data from it. The serial port of the 8051 is a full-duplex communication interface, allowing simultaneous data transmission and reception. The Serial Port Control Register (SCON) manages the operating mode of the serial port.

SM0 and SM1 are the mode selection bits that determine the working mode, as outlined in the table. SM2 enables multi-machine communication in modes 2 and 3. REN allows serial reception, while TB8 and RB8 represent the 9th bit of transmitted and received data, respectively, in modes 2 and 3. TI and RI are interrupt flags indicating whether data has been transmitted or received, set by hardware and cleared by software.

Since the RS-232 interface on a PC is managed by the 8250 chip, most PCs use 8-bit data communication. Therefore, the microcontroller should be configured to operate in mode 1, which is an 8-bit asynchronous communication mode with a variable baud rate.

In mode 1, the serial interface sends and receives 10-bit frames: one start bit (0), eight data bits, and one stop bit (1). When data is sent, it is first stored in the SBUF before being transmitted. After the data is sent, the TI flag is set to 1, indicating completion.

During reception, the data is read from the RxD pin. Once the first 1-to-0 transition is detected, the receiver starts. After the start bit is confirmed, the entire frame is received. If RI is 0 or SM2 is 0, the stop bit is stored in RB8, and the RI flag is set to 1, signaling that a complete frame has been received.

The baud rate is determined using Timer 1, which must be set to mode 2 (auto-reload mode). In this mode, TL1 acts as an 8-bit counter, and TH1 holds the constant value. When TL1 overflows, the value in TH1 is copied back to TL1, resetting the counter. This setup ensures a stable and consistent baud rate, based on the time constant set.

For example, if the oscillator frequency (fosc) is 6 MHz, and the desired baud rate is 1200, then TH1 and TL1 should both be set to 0xF3H.

The communication line typically uses a standard twisted pair cable, with a maximum effective distance of around 30 meters. For longer distances, optical isolation or current loop drivers may be required to extend the range up to 1000 meters. At lower baud rates like 300 bps, the communication is more reliable, and there are no special requirements for the communication cable.

Alumina Ceramic

Alumina Ceramic,Alumina Ceramic Ring,99 Alumina Ceramic Ring,Corrosion Resistance Of Alumina Ceramic Ring

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