1. Serial communication (transmitted one bit at a time): asynchronous communication (different clocks control data), synchronous communication;
Parallel communication: (each bit of a data byte is transmitted simultaneously using multiple data lines);
2. 8N1, one start bit (one byte), 8 data bits, and one stop bit.
The length of each byte field in the common SCI or UART serial data format (8N1) is 10 bit times (BIT TIME). The start bit START BIT is a dominant bit, which marks the beginning of the byte field.
The following are 8 data bits, with the least significant bit sent first. The stop bit STOP BIT is a recessive bit that marks the end of the byte field.
3.80C51 serial port structure
SBUF register: It is two physically independent receiving and transmitting buffers, which can send and receive data at the same time. The operation on the receiving buffer or the transmitting buffer can be distinguished by reading and writing instructions on SBUF. Thus, two independent external receiving and transmitting signal lines RXD and TXD can be controlled to send and receive data at the same time, realizing full-duplex.
SCON: A special function register used to set the serial port working mode, receive/send control and set status flags.
Four working modes:
Among them, fOSC is the clock frequency of the microcontroller; the baud rate refers to the number of bits sent (or received) per second by the serial port.
SM2: Multi-machine communication control bit. This is only used for multi-machine communication in mode 2 and mode 3. The transmitter SM2 = 1 (program control setting is required). The serial port of the receiver works in mode 2 or 3. When SM2 = 1, only when the 9th data bit (RB8) is 1, the first 8 bits of data received are sent to SBUF, and RI is set to issue an interrupt request to trigger a serial reception interrupt, otherwise the received data will be abandoned. When SM2 = 0, regardless of whether the data bit is 0 or 1, the data will be sent to SBUF, and RI will be set to issue an interrupt request. When working in mode 0, SM2 must be 0.
REN: Serial receive enable bit: When REN = 0, reception is prohibited; when REN = 1, reception is allowed.
TB8: In modes 2 and 3, TB8 is the 9th bit of data to be sent by the transmitter. In multi-machine communication, it represents the address or data to be transmitted. When TB8=0, it is data, and when TB8=1, it is address.
RB8: In methods 2 and 3, RB8 is the 9th bit of data received by the receiver, which happens to come from TB8 of the transmitter, thereby identifying the characteristics of the received data.
TI: Serial port sends interrupt request flag. When the CPU has sent a serial data, the SBUF register is empty, and the hardware sets TI to 1 to request an interrupt. After the CPU responds to the interrupt, the software clears TI.
RI: Serial port receive interrupt request flag. When the serial port receives a frame of serial data, the SBUF register is full, and the hardware sets RI to 1 to request an interrupt. After the CPU responds to the interrupt, the software clears RI.
PCON
Only SMOD (baud rate multiplication bit) is related to the serial port operation. When the serial port mode is 1, 2, or 3, SMOD = 1 doubles the baud rate, and SMOD = 0 when reset;
Baud rate = (2^SMOD/32) * Timer T1 overflow rate = (2^SMOD/32) * (fosc/12*(256-X))
like:
9600 X = 253 0xfd
4600 X=250 0xfa
2400 X=244 0xf4
Previous article:Driver writing for am2305 temperature and humidity sensor based on C8051F410
Next article:High impedance state and I/O port working state
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Feasibility of using QSPI + PSRAM to expand RAM for STM32
- Tailing Micro B91 Development Kit---MESH
- [NXP Rapid IoT Review] Week 2: Get familiar with the online GUI Rapid IoT Studio
- IoT-related applications of SensorTile.box
- How to solve the problem of glitch in ADC08D500 high output?
- National College Student Electronic Design Competition Quadcopter UAV Data Album
- A picture shows the layout of Qorvo and domestic replacement-penetration in various fields
- It is suggested to add a bonus to the post asking for advice, so that the questions raised will receive more positive and higher quality responses.
- [National Technology Low Power Series N32L43x Review] 08. Software and Hardware I2C Driver 1.5-inch 16-color grayscale OLED display
- Free application: Support Linux RISC-V development board, Sipeed LicheeRV 86