Personal Insights The best way to learn microcontrollers is to start programming them directly in C language, which saves time, is easier to learn, and allows for rapid progress. Let’s talk about microcontrollers. The STM32 and 51 microcontrollers are commonly used today, with abundant resources and a large market. The study of microcontrollers is a subject that emphasizes hands-on practice; you cannot just read books. However, it is essential to read first to gain a general understanding of the various functional registers of the microcontroller. To put it simply, using a microcontroller means controlling its various functional registers through software, which means controlling when the voltage levels on its pins are high or low. The changes in these high and low voltage levels control your system board, achieving the various functions we need. As for reading, you only need to understand what each pin of the microcontroller does and what functions it can achieve. The first or second time you read it, you may not understand everything, but that’s okay because you still lack practical experience. Therefore, I always say that reading about microcontrollers for two or three days is sufficient. You can read five or six novels in a day, but for microcontrollers, two or three readings in two or three days are enough; you don’t need to read in detail. If you don’t practice while learning about microcontrollers, it’s impossible to master them. There are two methods you can choose for practice.Method One: Buy a microcontroller learning board. It doesn’t need to have too many functions. For beginners, buying a board with too many features is unnecessary; you will never use many of them in your lifetime. I recommend a board with a running light, seven-segment display, standalone keyboard, matrix keyboard, ADC or DAC (the principle is the same), LCD, and buzzer. If you can proficiently use these components, you can say you have entered the world of microcontroller hardware. The rest is to practice designing circuits and continuously accumulate experience.Method Two: If you have an expert in microcontrollers nearby, ask them for help to set up a simple minimal system board for you. For an expert, creating a minimal system board only takes a minute, but for a beginner, it can be much more challenging because you need to understand the hardware to use it proficiently. If you don’t have such an expert around and can’t find anyone to help you, I suggest you buy one yourself. Having your own board is much more convenient, and you can use it for small experiments with microcontrollers in the future, which saves trouble. Once you have the microcontroller learning board, you need to practice more. Connect the learning board to your computer, open the debugging software, and learn how to use the debugging software. I recommend checking out related materials. Start with the simplest running light experiment. Once you can make those eight running lights flow according to your wishes, you have already entered the field; you will find microcontrollers are very fun.Driven by Interest People who do electronic design can really get addicted. Then make the seven-segment display light up. Once you master these two tasks, you will be hooked, and you will start considering which career path to take in your life. Interest is the best teacher. Recommended article: Sharing Embedded Development Experience: Treating Learning as a Hobby. Additionally, I would like to quote a line from the Analects:
When a person encounters something they cannot understand, they must study it thoroughly, to the point of forgetting to eat; they find joy in it and forget all worries, even unaware that old age is approaching.
Analects · Shu Er The general meaning is that a person, when faced with something they cannot comprehend, must study it thoroughly, to the point of forgetting to eat; they find joy in it and forget all worries, even unaware that old age is approaching. When writing programs, you will definitely encounter many problems. At that time, you can flip through books or ask others for help. When you get the answers, you will remember them for a lifetime. Knowledge must be applied in real life to solve practical problems; only then can it play its role. I can tell you that once you learn microcontrollers, you will never forget them. As a university student, you can learn microcontrollers while learning C language, which is also quite simple; it is just a tool. I advise you to learn it well, as you will definitely need it in the future. Otherwise, you will have to learn it later. It doesn’t matter if you don’t know any assembly language, but if you don’t know any C language, you will suffer in the future. Writing assembly code is efficient, but it is relatively difficult and verbose, especially when encountering algorithmic problems, which can be quite troublesome. Nowadays, the main frequency of microcontrollers is constantly increasing, and we no longer need such high-efficiency code because of the high-frequency clock. The ROM of microcontrollers is also continuously improving, which is sufficient to accommodate any code you write in C language. C language resources are abundant and easy to find, and its portability is excellent; you only need to change one IO port to write a temperature sensor program, and it can be used anywhere. Therefore, I advise everyone to use C language. In summary, as long as you have confidence, can persist in your endeavors, and have a strong will not to give up in the face of failure, learning microcontrollers will be a very easy task.Learning Practice Improving in microcontrollers relies heavily on practice. To learn microcontrollers well, software programming is essential. However, being familiar with hardware is also very important for mastering microcontrollers. To learn hardware well, hands-on practice is indispensable. We can improve our understanding and proficiency with certain chips by creating our own electronic projects. This way, we can gain a better understanding of the structure of the chips. I believe that once you complete your own electronic project, your level in microcontrollers will qualitatively improve. This is my experience and insights on learning microcontrollers, and I hope it helps enthusiasts learn microcontrollers well. Using microcontrollers means understanding the hardware structure of microcontrollers and the application of internal resources, learning various functional initialization settings in assembly or C language, and programming to achieve various functions.Step One: Using Digital I/O Use button input signals and light-emitting diodes to display output levels, which allows you to learn the digital I/O functions of the pins. When a certain button is pressed, a light-emitting diode lights up; this is the function of combinational logic in digital circuits. Although it is very simple, it allows you to learn the general programming ideas of microcontrollers. For example, many registers must be set to initialize the pins to enable digital input and output functions. Every time you use a function of the microcontroller, you must set the registers that control that function. This is a characteristic of microcontroller programming; do not be afraid of the trouble; all microcontrollers work this way.Step Two: Using Timers Learning to use timers allows you to implement sequential circuits with microcontrollers. The functionality of sequential circuits is powerful and has many applications in industrial and household electrical equipment control. For example, you can use a microcontroller to implement a corridor light switch with one button, which turns on the light for three minutes after pressing the button once and keeps the light on when the button is pressed twice in succession. If the button is pressed for more than 2 seconds, the light turns off. Digital integrated circuits can implement sequential circuits, programmable logic devices (PLD) can implement sequential circuits, and programmable controllers (PLC) can also implement sequential circuits, but only microcontrollers can do it most simply and at the lowest cost. The use of timers is very important; logical time control is the foundation of microcontroller usage.Step Three: Interrupts A characteristic of microcontrollers is that a program executes repeatedly, and each instruction in the program requires a certain execution time. If the program does not execute a certain instruction, the action of that instruction will not occur, which can delay many rapid events, such as the falling edge when a button is pressed. To enable the microcontroller to respond to rapid actions during normal program execution, the interrupt function must be used. This function interrupts the normal running program of the microcontroller when a rapid action occurs, processes the rapid action, and then returns to execute the normal program. The difficulty in using interrupts is knowing precisely when interrupts should not occur (masking interrupts) and when they should be allowed (enabling interrupts), which registers need to be set for a certain interrupt to take effect, what the program should do at the start of the interrupt, and what the program should do after the interrupt is completed, etc. Once you learn interrupts, you can write more complex structured programs. Such programs can do one thing while monitoring another; once the monitored event occurs, it interrupts the current task to handle the monitored event. Of course, you can also monitor multiple events. A vivid metaphor is that the interrupt function allows the microcontroller to eat from the bowl while watching the pot. Mastering the above three steps is equivalent to learning three moves of the Dragon Subduing Palm; you can barely protect yourself.Step Four: RS232 Communication with PC Microcontrollers all have USART interfaces, especially many models in the MSP430 series, which have two USART interfaces. The USART interface cannot be directly connected to the RS232 interface of a PC because their logic levels are different; a MAX3232 chip is needed for level conversion. The use of the USART interface is very important because it allows information exchange between the microcontroller and the PC. Although RS232 communication is not advanced, it is crucial for learning about interfaces. Correctly using the USART interface requires learning about communication protocols, programming the RS232 interface of the PC, and other knowledge. Imagine how interesting it would be if the data displayed on the microcontroller experiment board appeared on the PC monitor, and the keyboard signals from the PC could be displayed on the microcontroller experiment board!Step Five: Learning A/D Conversion The MAP430 microcontroller has a multi-channel 12-bit A/D converter, which allows the microcontroller to operate on analog signals, displaying and detecting voltage, current, and other signals. When learning, pay attention to concepts such as analog ground and digital ground, reference voltage, sampling time, conversion rate, and conversion error. A simple example of using the A/D conversion function is designing a voltmeter.Step Six: Learning PCI, I2C Interfaces, and LCD Interfaces The use of these interfaces makes it easier for microcontrollers to connect to external devices, which is very important for expanding the functionality of microcontrollers.Step Seven: Learning Comparison, Capture, and PWM Functions These functions enable the microcontroller to control motors, detect speed signals, and implement motor speed control functions. If you master the above seven steps, you can design general application systems, equivalent to learning ten moves of the Dragon Subduing Palm, and you can start attacking.Step Eight: Learning USB Interfaces, TCP/IP Interfaces, and Various Industrial Bus Designs Learning the hardware and software design of USB interfaces, TCP/IP interfaces, and various industrial buses is very important because this is the current direction of product development. Up to this point, you may not have reached the level of being invincible in the world, but you can be considered a microcontroller expert! The following text introduces the path to becoming a microcontroller expert through three plans.The Path to Becoming a Microcontroller Expert: Three Plans First of all, microcontrollers are not omnipotent, but without microcontrollers, nothing can be done. The demand for this in society is increasing. So what are you worried about? Are you afraid that you won’t have a place to use your skills? Are you worried that your salary is low or not high? I have been working in microcontrollers and my familiar industry for nearly ten years. Whether my skills are good or not, I should be humble and learn when necessary. After all, microcontrollers are always a system engineering project, and you cannot be familiar with and accurately grasp every aspect. The results of microcontroller work are just components. Because they are “components,” you need to provide corresponding physical dimensions, heat dissipation for the microcontroller system, installation conditions, and installation methods, which need to be coordinated with the environment provided by your upstream and downstream partners. It’s not enough to just complete the functions of the microcontroller and think everything is fine.Regarding project development, I recommend the article: Organizing Microcontroller Learning Methods and Product Development Processes。 Just in terms of the functions that microcontrollers need to achieve, if you can’t even implement the functions, what use do you have—this is just basic work. In fact, the environment provided by upstream and downstream partners often tests your design, and you may need to change various plans to achieve better results.Clearly, such upstream and downstream environments are a great resource for you, but some people may overlook them, making you more familiar with the usage and value of what you develop in this industry, which is a great reference for your future development.Unlike C or C++ programmers, who may feel frustrated when they don’t have a platform to showcase their skills.On the contrary, for microcontrollers, we can establish a platform for ourselves to showcase and develop our skills. From my understanding, microcontrollers are quite “low-level” and “hardware-oriented,” without too many complex data structures or intricate programming algorithms. As long as we understand and program from the perspective of microcontroller execution, that’s enough. A microcontroller can form an electronic system or just a smart node. There’s not much profound knowledge to study because we are merely users of microcontrollers; we shouldn’t elevate ourselves to the height of “research.” We are only at the height of “application.” Familiarizing yourself with the upstream and downstream environments and conditions of microcontrollers is not a difficult task. I hope that my understanding of these things can help newcomers and provide some food for thought.Planning Level One: When you have a certain age and human resources, you can start your own business and become a so-called half-boss.But saying it’s easy to be your own boss is also easy, and saying it’s not easy is also not easy.At that time, I rushed in with such apprehension.Many projects were taken on, and the cycles I set for myself were often short. I was often dealing with maintenance work for previous projects during the day and working on new projects until one or two in the morning. I don’t need to mention how tiring it is; sometimes I think I’m risking my life to make money! My wife didn’t quite agree with me starting my own business, so I told her that I might not be able to provide a stable income every month, but I guarantee that the average monthly income for the year will not be lower than it is now. Thus, I began to walk my own path.I’m not afraid of hardship; I’m not afraid of not reaping rewards for my efforts.What I’m afraid of is not being able to overcome my psychological barriers and the so-called “face” in certain situations. At the very least, we should use the “smallest cost” to pay for our “tuition.”It’s not embarrassing to say that I’ve paid quite a bit of “tuition.” A successful project is not about how good or strong your functions are, but about how much profit your successful development brings to your project partner; that is true success, even if you only earned a small development fee. When doing projects, don’t think too much about yourself; think from the perspective of the project partner.They trust you to hand over the project to you, so you should consider it from their perspective—sometimes their requirements may be a bit excessive, but as the saying goes, “Ignorance is no excuse.”Planning Level Two: Be a competent electronic engineer, both in software and hardware.There’s no need to learn too much; just learn some basics, and don’t follow trends; that’s unnecessary.Sometimes, even if you learn, if there are no corresponding development tasks, you’ll only learn the surface. However, just knowing the surface is fine; when you really need it, picking it up again will be much faster, and it can be considered a form of preparation. But you should at least be proficient in one relatively narrow system, right?! Don’t be embarrassed; I only know the 51 microcontroller. Let me talk about myself: I work in the industrial automation machine tool equipment industry: Proficient in 51, STM32, etc., familiar with other microcontrollers, proficient in 51 assembly, proficient in CPLD, semi-proficient in C51 (only used for some human-machine interface work), and roughly familiar with FPGA (wanting to master my own 51 IP core).
- Roughly familiar with ARM DSP, roughly familiar with ARM and DSP assembly, and understand C programming.
- Proficient in 3D modeling software SOLIDWORKS (can model my own circuit boards and mechanical equipment).
- Roughly familiar with most machining processes.
- Proficient in sheet metal and welding.
- Familiar with solutions for CNC equipment and machine tools.
For everyone, applying what you learn is essential. In the past, I wanted to learn everything but couldn’t use anything well. When I learned, I didn’t have a platform to apply it, so I was learning for the sake of learning. But at least when you need to use it, picking it up again will be quick. Take ARM as an example; I studied hard when I learned it, from its principles to implementation, and did many experiments, but now I use it less, and I’m left with only some conceptual knowledge. Therefore, it’s unnecessary to be proficient in everything; just being proficient in one thing, like the 51 microcontroller, from design, board production, procurement, soldering, to debugging into a finished product, if you have thought about it and mastered it, what are you afraid of? Even if you don’t get a high salary, you should still get a high annual salary. You should understand the saying, “It’s hard to find a good boss.”Planning Level Three: Be a qualified novice electronic engineer.For novices, my advice is:Don’t start with a five or ten-year plan; we are all ordinary people, and such plans are not suitable for ordinary people.If we can make plans for the next year or two, you are already remarkable. Every day is a new idea, every month is a change, let alone every year. As long as you are working hard and doing things steadily.Don’t make yourself too busy; leave half an hour each day to think about your “thoughts.”Do one thing well, then expand outwards; for electronic-related fields, ARM, DSP, and 51 are all interconnected.If you master one system, then other electronic systems are interconnected.What’s scary is that you don’t understand anything and are only half-knowledgeable.Wandering around with half a bucket of water is a bit frustrating and sad!