How to learn single-chip microcomputer, where to start to learn, how to get started

How to learn single-chip microcomputer, where to start to learn, how to get started

Whether it is a novice or a friend who is already in the industry, it is very important to learn single-chip technology and practical ability. If you only know how to start learning from the videos on the Internet and supporting textbooks, it is certain that you will never learn it . Why? The most important point in the learning of single-chip microcomputer is that it requires hands-on actual combat. If you just read the training materials, you may be able to understand a little bit, but after a period of time , you will forget it completely . There is an idiom in China that goes "on paper" , is often used to ridicule some people who have never practiced it at all, and they have a long story with confidence based on the knowledge they have learned from the book.

It is suggested here that you must build a suitable practical test site for yourself. Combined with specific practical objects, it is easy to understand the circuit configuration principle of the single-chip microcomputer and the programming principle of the single-chip microcomputer. For those who are not deep in the industry, It is recommended to give yourself a home-based intelligent IoT project, using single-chip microcomputer as the main control unit to build a satisfactory intelligent effect for the home. It is certain that learning through practical operation is better than reading online videos a hundred times. If Being able to have a one-to-one person with you will save you a lot of detours.

Share some relevant knowledge points on the structure and working principle of the timer counter of the 80C51 MCU. The timer counter is a relatively important peripheral in the MCU system. Its working mode is relatively flexible and the programming is simple. It is mainly used for timing control. Delay frequency measurement, pulse width measurement, signal generation signal detection, etc. In addition, the timer counter can also be used as a signal generator for the baud rate during serial communication.

A brief review of the concepts of clock cycle and machine cycle shared before. The clock cycle is the smallest time unit that lasts in a single-chip microcomputer, which is similar to the second in the clock. It refers to the reciprocal of the clock source, such as the clock crystal oscillator is 11.059, The clock cycle is 11.059 milliseconds, so the clock cycle is also called the oscillation cycle, which is the reciprocal of the oscillation frequency. The cycle and frequency are inversely proportional. With the concept of clock cycle, the concept of machine cycle can be defined. 80C51 MCU A machine cycle is defined as 12 clock cycles. In these 12 clock cycles, the CPU can complete the most basic operations. The machine cycle is also called the shortest time for the CPU to complete a basic operation.

After the clock cycle is available, the machine cycle time is easier to calculate. For example, for a 12-megabyte crystal oscillator, the clock cycle is 12 trillionths of a second, and a machine cycle is 12 times the clock cycle. 12 times 1/12 is a microsecond. Second, if it is a 6M clock crystal oscillator, the clock cycle is 1/6 trillionth of a second, and the clock cycle is 12 times the clock cycle, that is, 12 times 1/6 is 2 seconds. After understanding this, it is easy to talk about the following timer counter timing function.

There are two timing counters of 51 single-chip microcomputer, T0 timing counter and timing counter T1, and a slash counter is used for timing, so it has two functions, timing function and counting function, whether to use timing function or counting function, the inside of the single-chip microcomputer The control of all resources is achieved through the control of the special function register. If you want to use the timer counter, you must choose whether it is a timer function or a counting function. This is set by the special function register. Before using the law, it must be initialized , that is, whether to choose the timing function or the counting function.

If the C/T bit is set to 0, it means that you select the timing function, and setting it to 1 means that the counting function is selected, that is to say, it has two functions, one is the timing function and the other is the counting function, but no matter Whether it is a timing function or a counting function, the essence of the timing counter of 80C51 is an incrementing counter. If it is a timing function, it is to assign a 0 to this bit, and the timing function is selected. At this time, the timing counter is an incrementing one. Counter, it adds one to the internal machine cycle. Taking a 12-megabyte crystal oscillator as an example, the time of one machine cycle is 1/12 trillion times 12 microseconds, that is to say, it is an incrementing counter. After a machine cycle, each time a pulse of a machine cycle comes, the timer counters TH0 and TL0 will increase by one, so its essence is to add a counter. These two registers are actually special function registers, which are 8 bits respectively. A 16-bit timer counter is formed.

When the microcontroller is powered on and reset, the values ​​in TH0 and T20 are both 0, and the value in each machine cycle will increase by one. When the value in it is filled up, it will generate an action, that is, it will The overflow is called the overflow of the timer counter. It can be found that it is a 16-bit timer counter, so its maximum counting range can be determined, that is to say, it starts counting from 0. Every time a pulse of a machine cycle comes, it will be Add one, when it is added to TH0 and TL0 are both FF, then another machine cycle pulse, that is to say, after one machine cycle time, the value in this will be added by one, and it will overflow at this time. The TF0 hardware in the special function register of TCON is set to 1, that is to say, it will generate a flag bit. You can know that the timing time is up by querying this flag bit or setting the interrupt mode. This is its timing function.

If you are interested in single-chip microcomputer, you can check the content shared in previous issues , hoping to help everyone 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 the programming of single-chip microcomputer , and reply "Take me to learn" to view more content sharing .

Guess you like

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