80C51 serial port structure and principle (1-concept)

Publisher:asd123yuiLatest update time:2022-04-14 Source: eefocusKeywords:80C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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        


Keywords:80C51 Reference address:80C51 serial port structure and principle (1-concept)

Previous article:Driver writing for am2305 temperature and humidity sensor based on C8051F410
Next article:High impedance state and I/O port working state

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号