More than ten years of development experience describe the basic theoretical knowledge of single-chip microcomputer

More than ten years of development experience describe the basic theoretical knowledge of single-chip microcomputer

The basic theoretical knowledge of single-chip microcomputer includes analog circuit, digital circuit and C language knowledge. Analog circuit and digital circuit are abstract subjects. It takes some effort to learn these well, but before learning single-chip microcomputer, I feel that my analog circuit and digital circuit foundation is not good. If so, don't rush to get started with single-chip microcomputers first. First, you should review the knowledge of analog circuits and digital circuits you have learned to lay a solid foundation for learning single-chip microcomputers. Otherwise, your single-chip learning journey will not only be difficult and long, but will also Possibly halfway through.

A solid foundation of electronic technology is the key to learning single-chip microcomputers, which directly affects the speed of your single-chip learning process. Single-chip microcomputers belong to digital circuits, and their concepts, terms, hardware structures and principles are derived from digital circuits. The hardware structure and principle of the single-chip microcomputer can be easily understood, and the first step of learning can be easily taken, and self-confidence will also be established. It is generally recommended to learn analog circuits first and then learn digital circuits. A solid analog circuit foundation not only makes You can easily understand circuits designed by others, and you can also make circuits designed by yourself more reliable, thereby improving product quality.

Supplement some basic knowledge points of serial communication of single-chip microcomputer. The hardware layer has some regulations on electrical characteristics. For example, 232 will make some regulations on its interface. It will have what kind of interface characteristics and what kind of standards are used for mechanical interfaces. A regulation, including USB will have regulations on the signal line, there will be regulations on its electrical characteristics, and there will be regulations on the USB interface, whether the A-type interface is used, the B-type interface, or the type-C interface, and the interface standard is strict. It is stipulated that there are various standards to do work. Various manufacturers, including users, follow the standards to design hardware. Some hardware standards are only standards for electrical characteristics. For example, 485 actually only stipulates electrical characteristics, and does not Its interface is stipulated, so there will be various interfaces when making 485, some may use 232 interface, some use network cable interface, and some use simple terminal blocks.

The 51 single-chip microcomputer is asynchronous serial communication. How do the sender and receiver know when to start sending data and when to start receiving data? There is no clock signal line between TXD and RXD to synchronize the clock, and there is a clock signal line for synchronous transmission. , data transmission can be done under its control, the same clock is used by both the sender and the receiver, so both can monitor the clock to know when the data starts to be sent and when it starts to receive, if it is asynchronous serial communication, the line and ground When there is a level between them, the frame format when doing asynchronous serial communication, the level to be transmitted on this line is either 0V or 5V, if 0V appears on this line, the data transmitted is 0, If it is 5V, the data it transmits is logic 1.

When it comes to transmission, how do you indicate that the transmission is started now, and now that the transmission is over, the asynchronous serial communication signal line is at a high level by default when it is idle, so the line will always show 5V when it is idle. If the TXT side wants to send data, no matter the currently sent data is 1 and 0, for example, the data to be sent is 1010, the low order is sent first, the high order is sent later, the B side wants to send data, or the data transmission starts, you can Send a start bit before starting to send. Asynchronous serial communication is transmitted by characters one frame at a time. Before sending data, whether the current data is eight bits or seven bits is also set by the user.

For example, if the eight-bit data wants to tell the B side before sending the data, it needs to start sending data. Add a start bit and add a 0 to represent the start bit. If the bus is always in an idle state, the B side monitors the bus. Once it is pulled to a low level, the signal line will jump from a high level to a low level, and the B side can find it, because when monitoring the bus, it is considered that this line changes from a high level to a low level. To start a data transmission, the sender and receiver will agree on several data bits, such as receiving these eight data bits, after receiving and sending the eight data bits, pull it to a high level, so that the bus continues to be idle , first send a start bit, then send a data bit and then send a stop bit, the last high level is called the stop bit, a frame of data includes such several parts, start bit, data bit, stop bit, parity Check position.

When the bus is idle, it wants to start a transmission. In order to keep the bus at a low level, the B side knows that a data transmission is to be generated, and then the data can be sent, and it appears on the bus. It already knows to start sending data, and then It can receive eight data. After receiving eight data, it needs to add a stop bit to tell it that this frame of data has been sent. If you want to continue sending, you need to re-transmit according to the frame format. A stop bit. When the B side receives the stop bit, it knows that the data has been received and can be processed. When sending it again, it still follows the agreement and sends it according to the start bit data bit and the stop bit. Receive data according to the agreement just now.

Since it can be solved that both the sender and the receiver know when to start and when to end. For example, 1001 will be added, and a start bit will be added when sending this frame of data, which involves another concept, called the concept of baud rate, wave The bit rate refers to the number of bits of data transmitted in one second, and how many bits are transmitted in one second. The commonly used baud rates are known. When using the serial communication of the microcontroller, or opening the serial port of the computer. Sometimes you will often see baud rates, such as 300, then 600, 1200, 2400, 4800, 9600, and 115200, etc. Various baud rates represent how many bits are transmitted in one second, such as 9600, It means that 9600 bits need to be transmitted in one second, the specified baud rate, the baud rate determines the bit, the time interval between bits is 1/9600 second, how many bits to transmit in one second, when doing In asynchronous serial communication, because there is no clock signal line, how to ensure the transmitted data? After receiving it, we know that it is such a frame of data, which depends on the baud rate, and then processes it after receiving it.

The baud rate of the sender and receiver is the same, so the sender and receiver can parse the same data, and an error will occur when not a single value is processed. At the beginning, the line is at a high level, and the bus is idle when a data is to be sent. At the same time, there must be a circuit inside, which can convert the parallel data into a serial bit-by-bit data, and then make it appear on the bus. At the same time, the serial port of the microcontroller can also help increase the start bit of the hardware. And the stop bit, the actual serial port is relatively simple. When sending a frame of data, to send a data to operate on the microcontroller, that is, write the data to a special function, and then it will pass the internal circuit. The data is converted into serial data, and a start bit and a stop bit are added at the same time, so if you want to send 1010, you need to add a start bit 0, first pull the bus to a low level to know that you want to send data. , and then send such a frame of data.

If you are interested in single-chip microcomputer, you can check the content shared in previous issues . I hope it can help you to take some detours on the road of learning single-chip microcomputer . If you want to get started with single-chip microcomputer, you can continue to pay attention to Chuangwei single-chip microcomputer programming . Reply "Take me to learn" to see more content sharing .

Guess you like

Origin blog.csdn.net/m0_66707146/article/details/123851114