Why do you feel at a loss after learning STM32 for a few days, your posture is wrong

Why have you been learning for a few days STM32 feels dazed, your posture is wrong

Yes, you feel right. In fact, you already have a vague answer. You have never been in contact with any microcontroller before. In fact, your problem can be attributed to the following reasons:

4c932e6d1c7a98f615c4ff175bff24d9.png

1. The lack of basic knowledge of MCU

2. The detailed work understanding of the microcontroller (that is, STM32) is not clear.

According to the description of the sequence of the entire training stage, the following is a more detailed interpretation to explain the problem.

1. Special terminology

For MCU, without touching the detailed functions, there are only a bunch of special terms, cross-compilation, kernel, adder/divider, coprocessor, algorithm accelerator, instruction set, floating-point operation, pipeline, Harvard structure, register (general purpose and peripherals), interrupts and exceptions, FLASH, RAM, Cache (cache), SDRAM (refresh duration), USART (baud rate, stop bit, parity), CAN, SPI (chip select) and I2C, etc., Some of them belong to basic knowledge, and some belong to the knowledge points that need to be understood in advanced. The understanding of these terms is the first threshold for beginners. If you do not understand some special terms, the combined sentences will become more difficult. Understood, here is my method of further study: When encountering professional terms that you do not understand, go to the Internet to find out about it, and find a notebook or computer to record it in the form of a document, review it for a period of time, a good memory is not as good as a bad writing, it is recommended here <>3 Authoritative Guide>, which explains the core knowledge that needs to be understood in the study of single-chip microcomputer.

2. Chip workflow

The terminology is not too difficult to remember. Even if you forget to review it, it will be brief. After passing this hurdle, the next step is to understand the chip execution process and what we have to do to make the chip work.

1. After power-on, the chip resets and starts

2. The MCU reads the instructions and data from the FLASH through the instruction/data bus respectively, and cooperates with the analysis and execution, in which the variable data is processed through the RAM and the general-purpose registers (that is, the internal registers of R0~R12).

3. According to the executed instructions, configure and operate the registers of the peripherals, thereby driving the corresponding peripherals to achieve detailed functions

4. Cooperate with upper-layer combinational logic, combine peripheral functions, and implement all requirements of detailed applications

The above is the working process of the chip, and as a microcontroller developer, the implemented code is the program placed in the FLASH, which consists of the officially provided SDK package and the peripheral driver defined by the user tailoring implementation. According to the above process, it includes:

The initialization of the stack during the startup process of the chip, the processing of system-related peripherals (such as clock) => this part is provided by the manufacturer, we can put the file into the project, take STM32 as an example, it is the startup file startup_xxx.s and system initialization SystemInit function

Configure the peripheral modules required by the application. If you watch the online teaching video, it is directly initialized from this step, especially the implementation of STM32 based on STM32CubeMx, it will tell you that this writing meets the requirements, if you are not willing to delve into it. It doesn't matter, when you delve into this thing, you will find that no one tells why you wrote it like this, and confusion will naturally come. In fact, this part is the embedded so-called experience component.

72965702dfd6c7bc381dc5cdb249db52.png

If most peripheral modules need to be clock enabled, GPIO needs to configure pin pull-up/pull-down, push-pull/open-drain, USART configuration mode, baud rate, parity, stop bit, data bit, and To consider the port multiplexing corresponding to GPIO, I2C should consider the master-slave mode, and determine the module clock according to the required transmission rate. In addition to considering pin multiplexing and timing, SDRAM also needs to calculate the refresh duration to ensure data stability. These knowledge theory The above are all accumulated in the work for a long time. After the project requirements are determined, according to the chip and device selection, the drawing and layout of the hardware PCB can be determined, and the functional requirements can also be determined. Main mode, and according to the read and write timing of EPPROM and the performance of the chip, considering the balance of efficiency and stability, the rate of I2C can be determined. Considering layout and other requirements, the multiplexing pins corresponding to I2C can also be determined. In fact, For real projects, all from

Requirements => project proposal => software and hardware framework => software driver

The video you watch starts directly from the software driver. If you don’t know the background and background, you will be confused. As for how to convert your thinking and learn, you can refer to my previous summary. At the end, there are also my instructions on embedded entry.

Listening to the Heartbeat: Shifting Thinking Learning Embedded --Methods and Summary 111 Endorsed ?7 Commentary Article

3. Upper-layer application logic implementation

The application logic implementation with peripherals is actually the most complex part of the project, including the interaction between the front and back systems, the possible RTOS application and protocol porting, GUI management operations, and other modules such as wifi module, Bluetooth module interaction, However, this part belongs to the advanced content. After you have a certain understanding of the peripheral modules, this part should also have its own learning method, and I will not repeat it here.

This answer ends here. This is just a summary of what I know about the single-chip microcomputer. Although the single-chip microcomputer does not need to innovate and develop unknown technologies, it affects the entire realization from the bottom layer of the chip to the software interface, including the understanding of modern computer technology. All the essential technologies in the direction of microprocessors also need continuous learning in order not to be abandoned by the times. In addition, I hope you can also sum up your own methods, and you will get better and better on this road. If you have learning needs for embedded Linux, you can also read my answer.

My first development board was an arduino, and I also used arduino to learn electronics.

My first dev board was also an arduino uno. Then to 8266, then to stm32, and then to 51 of the school, isn't the path very strange? In fact, what is the most important thing to learn single-chip microcomputer? It’s interest and sense of accomplishment. In the early years, 51 used compilation. How many people were discouraged by that thing? The first personal project I took on was compilation. The ghost knows that I wrote a program for half a month, people All vomited.

Let's talk about 51 at this time, you install a keil, and then, install the 51 support package, light the program, and then compile the hex, what to download, stcisp, do you have to restart it for burning?

Say stm32 again. Did you get the 407zgt6 development board from Punctual Atomic or Wildfire? It's a big pile of stuff, and I don't know what's on it, a bunch of pin headers, a bunch of serial ports, network ports, and a display screen. No matter, install mdk5 first, then install the f4 support package, and then turn on the lights of Atomic Brother, and then use serial port 340 or stlink for programming, do you need to configure the programming address, and do you have to write your own for the h7 series? External flash configuration file, because the on-chip space is very small. You have finished this pile, is it a big head, ah yes, and the size of the network disk, I remember there are several GB, it has been downloaded for two days.

Therefore, this series can easily dissuade many students. arduino is stupid, nothing, d13 lights, a blue data cable, install arduino ide, no need to install drivers, click install during the installation process, just open the ide, click the program blinker, automatically identify the serial port, a typeb The printer line clicks download, ok, d13 flashes. Make a few more pwm, make an OLED screen, make a relay and a bluetooth module, and you can directly make a small smart home. A sense of accomplishment, right?

Then he will encounter various problems. If pwm wants to control the motor, it can't adjust the frequency, right? It can only rewrite the timer. If there is no uno analog output, if there is only one serial port, if only two external interrupts are not enough Use it right, if there is no network port, you can only use 5100 or 5500 to expand, right, after expanding the network port, the flash is not enough, right, many restrictions have appeared. At this time, you will be like a smoking addiction, and you will go crazy to find a way to overcome it, if you choose mega or due. Or switch to stm32, some problems can be solved directly with atmel studio development. Interest will drive you to dig in.

e5e915c27b0ce5af1281f3829a0b2b35.png

And stm32 is at a loss for further study, that's right, because stm32, the domestic development board, is all for you, let you mess around there, ghosts don't want to see it, go and see the official evaluation from STMicroelectronics What does the board look like. Use the system board of Defeilai, add some expansion boards and Dupont cables, and cooperate with a good bootloader, so that beginners have more time to ponder the essential things, instead of wasting on looking at the schematic diagram of your big development board. Look at the information of a few g, it is correct. Of course, I feel that these will arouse the dissatisfaction of the two domestic st education giants, but I still have to say, although I am 32 in the university reading the book of atom and wildfire, I am also grateful to the two for their efforts in embedded teaching in China. (I also bought a lot of development boards and modules from two companies, some of which are several thousand in size, and an atomic oscilloscope, although I fell it), but it is not like this, it is right, the essence of education, This is to continue to explore, to innovate, and to reflect.

At the beginning of this year, I recorded a relatively systematic introductory single-chip microcomputer tutorial. If you want, you can get it from me. It's free, and you can send me a private message. You can also get it by clicking on my avatar in black font and adding 隱重麺.

Guess you like

Origin blog.csdn.net/danpianji777/article/details/124046129