MCU learning experience experience_Summary

Microcontroller Introduction

The single-chip microcomputer is mainly composed of three parts: an operator, a controller and a register. Among them, the arithmetic unit consists of an arithmetic logic unit (ALU), an accumulator, a register, and the like. First, the accumulator and the register input two 8-bit source data to the ALU. Next, the ALU completes the logic operation of the source data, and finally stores the operation result in a register. The controller consists of a program counter, an instruction register, an instruction decoder, a timing generator, an operation controller, etc. It is an "organization" for issuing commands for coordinating the operation of various parts of the entire system; the registers mainly have Accumulator A, data register DR, instruction register IR, instruction decoder ID, program counter PC, address register AR, and the like.

In the microprocessor, the internal operators, controllers, and registers are connected to each other. The controller issues operation commands to each part. After the operator receives the commands, it performs corresponding operations and stores the results in the corresponding registers. .

MCU learning experience experience_Summary

The basic working principle of the one-chip computer

The process that the one-chip computer finishes the task assigned to it automatically, that is to say the process that the one-chip computer executes the procedure, that is to say a piece of the procedure that carries out the order, the so-called instruction is to write down the order that requires the one-chip computer to carry out various operation, this is in the design The instruction system assigned to it by the personnel determines that one instruction corresponds to a basic operation; all instructions that can be executed by the microcontroller are the instruction system of the microcontroller, and different types of single-chip microcomputers have different instruction systems.

In order for the microcontroller to automate a specific task, the problems to be solved must be programmed into a series of instructions (these instructions must be instructions that the selected microcontroller can recognize and execute). This set of instructions becomes a program and the program needs Stored in advance in a memory-enabled component—memory. The memory consists of a number of storage units (smallest units of storage). Just like the building has many rooms, the instructions are stored in these units. The instructions in the units are taken out and executed just like every room in the building is allocated. Just like a unique room number, each storage unit must also be assigned a unique address number. This address number is called the address of the storage unit so that if the address of the storage unit is known, the storage unit can be found. The stored instructions are Can be removed and then executed again.

The program is usually executed sequentially, so the instructions in the program are also stored in a sequence. When the program is executed, the microcontroller must be able to take out and execute these instructions. There must be a component that can track the address of the instruction. It is the program counter PC (included in the CPU). When starting the program execution, the PC is given the address of the first instruction in the program, and then each command to be executed is obtained. The content of the PC is automatically increased. The increase is determined by the length of this instruction, which may be 1, 2 or 3, to point to the starting address of the next instruction to ensure that the instructions are executed sequentially.

MCU learning experience experience_Summary

Microcontroller to learn content

The first step: the application of digital I/O

In most SCM experiments, the marquee experiment is a typical application of digital I/O, and it is also the reason why the Marquee's experiment was arranged first. By setting or clearing the I/O pin of the microcontroller to turn the LED on or off, it is simple, but this is the logic function in the digital circuit. The experiment of the mathematical I/O application is also a key experiment. When a key is pressed, an LED is lighted. The digital I/O experiment teaches us the programming thought of the one-chip computer, must dispose the corresponding register of the one-chip computer first, in order to initialize I/O pin, can make this pin possess digital input and output function. The use of a built-in or external function of the microcontroller is to set and initialize the register associated with the function. This is the characteristic of the microcontroller programming. As few as 4, 5 function to get, more than a dozen lines, have patience, do not be afraid of trouble, all the microcontroller is this way.

The second step: RS232 serial communication

The single-chip microcomputer has UART interface. This simple and old communication method can directly communicate with the RS232 interface of our PC. Of course, because of the different level logic between them, an RS232 level-shifting chip must be used to connect with the PC. For example, Max232 chip.

The use of the UART interface is very important. Through this interface, we can exchange information between the microcontroller and the PC, and the concept of "interface" learning is also introduced. Using UART interface will also learn the most simple and common communication protocols and other knowledge. We can also use the serial port debugging software of the PC to monitor the data of the SCM experiment board. If you think about it, it will be a magical thing.

The third step: the use of the timer

Learning the use of timers, you can use the microcontroller to achieve a typical sequential logic circuit. The application of sequential logic circuits is the most powerful and widest. For example, in industrial control, we let a switch open and close once every second. This scheme can be realized by ordinary digital integrated circuits, or it can be realized by PLC, or can be realized by CPLD or FPGA, but only the implementation of the single-chip microcomputer is the simplest and the cost is the most economical. The timer is the most important one among the internal resources of the one-chip computer, it is the foundation that the logic and time control realize.

Step 4: Interruption

In the SCM software design architecture, a cycle of program execution is a feature and a drawback. The execution of each operation instruction requires a certain execution time. If the program does not execute the instruction, the operation of the instruction will not be triggered. This will ignore many fast-occurring events, such as the rising edge of square wave frequency detection. The interrupt function is designed to respond immediately to external events when the microcontroller program is operating normally. When the interrupt function is executed, the SCM prioritizes the interrupt program. After the interrupt processing is completed, it returns to the normal program execution of the SCM. The mechanism of the interrupt is relatively easy to understand, but when to open the interrupt, when to close, mask the interrupt, how to configure to enable some of the functions of the interrupt, which programs to be executed in the interrupt, which needs to meet these requirements Take time to understand and practice. After interrupting learning, you can write programs with complex structure functions. You can flash a small LED light while scanning the keys, sending data, or doing multiple things... For example, the interrupt function can make the microcontroller eat In the bowl, I looked at the pot. According to the legendary 8020 law, if you have mastered the above four steps, then you have learned 80% of the content.

MCU learning experience experience_Summary

The fifth step: I2C, SPI communication interface

After all, the microcontroller system resources are limited, and the use of I2C, SPI communication interface to expand peripherals is the most commonly used method is also a very important method. Both of these communication interfaces are serial communication interfaces. Typical basic experiments are I2C EEPROM experiments and SPI SD card read and write experiments.

Step Six: Compare, Capture, PWM Function

In comparison, the capture and PWM functions make the microcontroller more suitable for motor control, signal detection, and adjustment of motor speed and step size. PWM wave is now the main means of LED dimming. Here has been the initial contact with the analog circuit part of the digital circuit.

Step Seven: A/D Modulo Acquisition

The single-chip microcomputer basically comes with multi-channel A/D analog-to-digital converters. Through these A/D converters, the MCU can acquire analog signals for detecting signals such as voltage and current. When learning, important concepts such as analog ground and digital ground, reference voltage, sampling time, slew rate, and conversion error should be distinguished. This step learned the digital circuit to control the analog circuit part, and the simplest A/D analog-to-digital converter is a voltmeter experiment.

Step 8: Learn USB Interface, TCP/IP Protocol, Industrial Bus

The current mainstream communication protocol is the USB protocol—the high-speed communication interface between the lower computer and the host computer; TCP/IP—the communication protocol used by the universal Internet; the industrial bus—the protocol for communication between various modules of industrial control such as Modbus and CANOpen. . These will be applied in future projects, integrated into the firmware in the microcontroller, and is also a development direction of current product development.

MCU learning experience experience_Summary

Learn MCU experience

First of all, learning a single-chip microcomputer must have the necessary basis: Electronic technology must have the theoretical basis of digital circuits and analog circuits, the personality is a digital circuit; programming language requires assembly language or C language. In order to become a master of SCM, it is recommended that beginners first learn assembly language. When they learn almost, they will transfer to C language learning. Although assembly language is a low-level language, programming efficiency is low, but it has the advantages of shorter target code, less memory, faster execution than C language, and more importantly, it enables beginners to become familiar with the internal structure of the microcontroller as quickly as possible. Accurate control. Assembly language is involved in the SCM teaching materials, do not need to purchase textbooks and learning alone. C language is a science, there are many professional books to explain, and has an absolute advantage for our future programming career, so in-depth study, do not think that watching a certain video tutorial thought that mastered the C language, That's just part of the C language. Where to recommend to everyone a microcontroller C language programming reference book, Ma Zhongmei waiting, Beijing University of Aeronautics and Astronautics Press published "Single-chip C language application design" requires C language basis. If you have not studied C language, it is recommended to study the C language programming written by Tan Haoqiang of Tsinghua University. This is a well written and easy-to-understand book.

Second, selection of SCM textbooks. MCU is a technology that attaches great importance to practice and cannot always read books, but it should be read first to learn it. It has a necessary understanding and sensory understanding of the pin, internal structure, registers and principles of the MCU. It is how it works and is capable of doing What are these? At the beginning, maybe you don't understand, but it doesn't matter because you lack practical experience. Microcontrollers are widely used at the moment, so various manufacturers have introduced their own microcontrollers, according to the internal structure of the system points: 51 series, PIC series, AVR series, Motorola, etc. ... We do not need to learn everything! Because their programming method and debugging process and the internal instruction structure must be similar, as long as learning a proficient on OK! Especially programming in C language, it is almost no matter what factions, but we have to choose a representative range of knowledge, and easy to get started, books and more. In general, the MCS-51 series single-chip microcomputer has been widely popularized and applied, and it has more information on the market and many people use it. Recommend some reference books for everyone, only one book is enough to pull. Title: "New MCS-51 microcontroller application design," Harbin Institute of Technology published author: Yigang; Title: "Principles and Applications", Higher Education Press, author: Yigang etc; Title: "Advanced Microcontroller Tutorial : application and design ", Beijing University of Aeronautics and Astronautics Press author: He Limin. There are many related teaching materials, not listed here.

Then, it is the selection of development tools and development environment. The selection of a suitable learning board is generally incapable of understanding for beginners. If economic conditions permit, I am very interested in microcontrollers and have the intention of working in related industries, encourage everyone to buy. To say casually, the function of the learning board is too demanding. It is almost like a water lamp, a digital tube, an independent keyboard, a matrix keyboard, an AD or a DA, a liquid crystal, a buzzer, etc. After all, the price of a full-featured product is relatively high. The emulator is not only familiar but also unfamiliar to beginners. This is mainly because the price of traditional emulators on the market is more than a thousand dollars. It is not a small expense for those who are not very economical. At the same time, the emulator is used to improve the efficiency of the debugging program, and it is not necessary. If you do not have the emulator and you encounter errors in the program, you have to think hard and write it repeatedly. Just recommend it, learning forest electronic 51tracer simulator, interested friends can look at. With the single-chip computer tutorial board, look at the next instruction manual, familiar with the learning board, open-book useful. Afterwards, you have to practice on your own, connect the learning board to the computer, learn how to use the software first, then start with the simplest running light experiment, and control the lights according to your own wishes. When you finish, you will Will find this is how pleasant. It's so much fun that you think it's not learning, it's just playing. When you find out that the SCM can work according to the program you write, you'll feel very excited and happy than doing anything. On the MCU, really. Many websites say that

In order to compliment one of the experiments, you will be complimented to tell you “Congratulations on you and learned” that you have learned the MCU. This is a bit ridiculous. This can only tell you that you have passed and you have to understand and use it. However, there are too many functions that can be accomplished by a single-chip microcomputer, especially the control of peripheral devices. In combination, many unexpected products can be designed. Therefore, in addition to getting started, proficiency can never be easy to say.

Finally, after being mastered and applied, it can be said that you have already started the hardware for the SCM, and the rest is to practice designing the circuit and accumulate experience. In the end, you completely design a circuit with a personal style and product so that you are a microcontroller with a high hand. As long as the first pass has passed, the road behind will go much better. It is difficult at the beginning of everything. Everyone may have heard it. Nowadays, a number of electronic newspapers and magazines such as: "electronic production" "Radio" "Electronics" "Electronic World" have opened a detailed MCU tutorial column, for those who want to learn MCU is very helpful, can say at the moment SCM tutorial environment is the best, there are networks, there are books, newspapers and magazines, as well as video tutorials, component procurement is also very abundant, and related equipment and more cheap. If you can take two hours each day to study, one month sooner or three months slower.

MCU learning experience experience_Summary

Experience summary

(1) There is no shortcut to learning SCM, do not expect to learn two or three days, to persevere, focus on accumulation.

(2) Do not worship the master, do not believe in genius, most people are not genius (I believe you are not)!

(3) Single-chip microcomputer is a discipline with strong practicality and practicality. It requires more hands-on and more experiments.

(4) Learn to refer to other people's programs, reduce your own time, and quickly increase your programming potential.

(5) Encounter problems You can use the Internet to search for answers and help yourself, which can greatly reduce your development time.

(6) Make more friends and more exchanges. Technology will only progress through constant accumulation and exchange. Closed and self-contained will only be more backward.

Crossover Network Cable

Cross-over Ethernet Cable is also called cross wire. When the crystal head made by different standards at both ends of the wire is T568A at one end and T568B at the other end, then it is the cross wiring mode.

The crossover cable is used to connect ADSL modems to the HUB HUB (related to the MODEM design, but not all), the HUB to HUB connection without a stage port, and the two computers to each other directly through the network card.The production method is basically the same as above, except that the online order is different from 568B, which adopts the method of exchanging 1-3,2-6, that is, one end is made with 568B and the other end with 568A.

CAT5E Patch Cables (3)

Crossover Lan Cable,Crossover Network Cable,Ethernet Crossover Cable,Lan Cable Cross Connection

Shenzhen Kingwire Electronics Co., Ltd. , https://www.kingwires.com