
We encourage clear philosophical thinking in programming rather than rigid rules. I do not expect you to agree with everything, as they are merely opinions that change over time. However, if I had not written them down until now, these opinions, based on much experience, have long accumulated in my mind. Therefore, I hope these insights can help you understand how to plan the details of a program. (I have yet to see a good article on how to plan the whole thing, but this part could be part of a course.) If you can discover their characteristics, that’s great; if you disagree, that’s also fine. But if it inspires you to think about why you disagree, that would be even better. In any case, you should not blindly follow the way I program; try to complete the program using the method you think is best. Please do this consistently and without mercy.
01
Formatting Issues
A program is a publication. This means that programmers will read it first (perhaps you will read it days, weeks, or years later), and only then will it be for the machine. The machine’s happiness is that the program can compile; it does not care how beautifully the program is written, but people should maintain the beauty of the program. Sometimes people overly concern themselves with producing beautiful outputs using fancy printers, which merely highlight all prepositions in bold text, details irrelevant to the program. While many believe that programs should be written in the style described by Algol.68 (some systems even require programs to be written in that style), clear programs do not become clearer because of such presentation; they only make bad programs look more ridiculous.For clear programs, formatting standards have always been crucial. Of course, it is well known that indentation is the most useful, but when ink obscures intent, it controls formatting. Therefore, even if you insist on using a simple old typewriter output, you should be aware of foolish formatting. Avoid excessive embellishment, such as keeping comments concise and flexible. Express what you want to say through the program in a neat and consistent manner. Moving on.
02
Variable Naming
For variable names, length is not the value of the name; clarity of expression is. Uncommonly used global variables may have long names, like maxphysaddr. The array index used in each line of a loop does not need a more detailed name than i. Using index or elementnumber would input more letters (or call the text editor) and obscure the details of the computation. When variable names are long, it becomes difficult to understand what is happening. To some extent, this is a formatting issue, as seen below.
vs.
Problems in real examples can become worse. So just treat indices as symbols. Pointers also need reasonable symbols. np merely serves as a mnemonic for nodepointer. If you consistently follow naming conventions, it will be easy to infer that np stands for “node pointer.” More will be mentioned in the next article.At the same time, consistency is extremely important in other aspects of programming readability. If a variable name is maxphysaddr, do not name a sibling variable lowestaddress.Finally, I tend to favor “minimum length” but “maximum information” in naming, allowing context to fill in the rest. For example, global variables rarely have contextual help for understanding, so their naming needs to be relatively clear. Therefore, I refer to maxphyaddr as a global variable name, while np does not necessarily mean NodePoint for locally defined and used pointers. This is a matter of taste, but taste is related to clarity.I avoid embedding capital letters in naming; their readability is too awkward, much like poor formatting that is annoying.
03
Use of Pointers
C is unusual because it allows pointers to point to anything. Pointers are sharp tools; like any such tool, when used properly, they can produce delightful productivity, but when misused, they can cause great destruction. Pointers have a bad reputation in academia because they are too dangerous and can become inexplicably bad. But I believe they are powerful symbols that can help us express ourselves clearly.Consider: when a pointer points to an object, for that object, it is precisely just a name, nothing else. It sounds trivial, but look at the two expressions below:
The first points to a node, while the second computes (one could say) the same node. But the second form is a less easily understood expression. Here’s the explanation: we must know what node is, what i is, and the rules that relate i and node to the surrounding program. An isolated expression does not indicate that i is a valid index for node, let alone that it is the index for the element we want.If i, j, and k are all indices in the node array, it can be easy to make mistakes, and even the compiler cannot help find the errors. It is especially easy to make mistakes when passing parameters to subroutines: a pointer is just a single parameter; but in the receiving subroutine, one must think of the array and index as a whole.Computing as an object expression itself is less perceptible than the address of that object and is prone to errors. Correctly using pointers can simplify code:
vs.
If you want to get the next element’s type, it can be
or
i moves forward, but the rest of the expression must remain unchanged; with pointers, you only need to do one thing, which is to move the pointer forward.Also consider formatting factors. For handling continuous structures, using pointers is more readable than using expressions: it requires less ink, and the performance consumption of the compiler and computer is also minimal. A related issue is that pointer types affect the correct use of pointers, which allows for some useful error detection at compile time to check that array sequences cannot be separated. Moreover, if it is a structure, then its label fields are hints of its type. Therefore
is sufficient to make it clear. If it is an indexed array, the array will take some carefully chosen names, and the expressions will become longer:
Moreover, as the examples become larger, the extra characters become more annoying.In general, if you find that your code contains many similar and complex expressions, and those expressions compute elements in a data structure, wisely using pointers can eliminate these issues. Consider
that looks like using a composite expression to represent p. Sometimes it is worth using a temporary variable (here p) or extracting the operation into a macro.
04
Procedure Names
Procedure names should indicate what they do, and function names should indicate what they return. Functions are often used in expressions like if, so readability is important.
is not very helpful because it does not indicate whether checksize returns true on error or non-error. Instead
makes this point clear and is less likely to cause errors in regular use.
05
Comments
This is a subtle issue that requires personal experience and judgment. For some reasons, I tend to prefer to eliminate comments. First, if the code is clear and uses standard type names and variable names, it should be understandable from the code itself. Second, the compiler cannot check comments, so they cannot guarantee accuracy, especially after the code has been modified. Misleading comments can be very confusing. Third, formatting issues: comments can make code messy.But sometimes I will write comments, like the following, just to introduce them. For example: explaining the use and type of global variables (I always write comments in large programs); as an introduction to an unusual or critical process; or marking a section of large calculations.Here is an example of a bad commenting style:
And an even worse practice:
Don’t laugh just yet; wait until you see it in reality.Perhaps aside from declarations of important data structures (comments on data are usually more helpful than comments on algorithms), such crucial parts should avoid “cute” formatting and lengthy comments; basically, it’s best not to write comments at all. If the code needs comments to explain it, the best approach is to rewrite the code to make it easier to understand. This brings us to complexity.
06
Complexity
Many programs are overly complex, more so than necessary to effectively solve the problem. Why is this? Mostly due to poor design, but I will skip this issue as it is too large. However, programs often become complex at the micro level, and these can be addressed here.
- Rule 1: Do not assume where a program will spend its runtime. Bottlenecks always appear in unexpected places; until you confirm where the bottleneck is, do not try to guess and speed it up.
- Rule 2: Measure. Do not optimize speed without measuring the code first, unless you find the most time-consuming part of the code; otherwise, do not do it.
- Rule 3: When n is small (usually very small), fancy algorithms run slowly. Fancy algorithms have a high constant level of complexity. Do not use fancy algorithms until you are sure n is always large. (Even if n grows, prioritize Rule 2). For common problems,binary trees are always more efficient than splay trees.
- Rule 4: Fancy algorithms are more prone to bugs and harder to implement. Try to use simple algorithms with simple data structures.
Almost all practical programs use the following data structures:
- Arrays
- Linked Lists
- Hash Tables
- Binary Trees
Of course, one must also be prepared to flexibly combine these data structures, such as using a hash table implemented as a linked list of character arrays.
- Rule 5: Center on data. If you choose the appropriate data structure and organize everything neatly, the algorithm is always self-evident. The core of programming is data structures, not algorithms. (Refer to Brooks p. 102)
- Rule 6: There is no Rule 6.
07
Data Programming
Unlike many if statements, algorithms or algorithm details are usually encoded in compact, efficient, and clear data. The work at hand can be encoded, ultimately due to its complexity being composed of unrelated details. Analysis tables are a typical example, encoding the syntax of programming languages through a form of parsing fixed, simple code segments. Finite state machines are particularly suitable for this form of processing, but almost any program that benefits from constructing data-driven algorithms involves “parsing” the input of certain abstract data types into sequences, which consist of some independent “actions.”Perhaps the most interesting aspect of this design is that table structures can sometimes be generated by another program (a classic case is a parsing generator). A more down-to-earth example is if the operating system is driven by a set of tables that connect I/O requests to the corresponding device drivers, then a program can “configure” the system, which can read descriptions of certain special devices connected to suspicious machines and print the corresponding tables.Data-driven programs are uncommon among beginners due to Pascal’s authoritarianism. Pascal, like its founder, firmly believes that code should be separate from data. Thus (at least in its original form), it cannot create initialized data. This is contrary to the theories of Turing and von Neumann, which define the basic principles of stored-program computers. Code and data are the same, or at least can be considered so. How else can we explain how compilers work? (Functional languages have similar issues with I/O).
08
Function Pointers
Another result of Pascal’s authoritarianism is that beginners do not use function pointers. (In Pascal, functions are not treated as variables.) Using function pointers to handle coding complexity has some interesting aspects.Programs pointed to by pointers have a certain complexity. These programs must adhere to some standard protocols, such as requiring a set of programs that all have the same calls. Beyond that, what needs to be implemented is merely to complete the business, and the complexity is dispersed.A claim of the protocol is that since all the functions used are similar, their behavior must also be similar. This helps with simple documentation, testing, program extension, and even distributing programs over a network—remote procedure calls can be encoded through this protocol.I believe the core of object-oriented programming is the clear use of function pointers. Specify a series of operations to be performed on the data and the entire set of data types that respond to those operations. The simplest way to bring the program together is to use a set of function pointers for each type. In short, this defines classes and methods. Of course, object-oriented languages provide more elegant syntax, derived types, etc., but conceptually, they do not propose anything extra.The combination of data-driven programs and function pointers becomes a surprisingly effective working method. In my experience, this approach often yields surprising results. Even without object-oriented languages, one can achieve 90% of the benefits without extra work and manage results better. I cannot recommend a higher standard of implementation. All my programs are organized and managed in this way, and after multiple developments, they have all been stable—far superior to methods lacking constraints. Perhaps as they say: in the long run, constraints yield rich rewards.
09
File Inclusion
Simple rule: when including files, never nest includes. If the required files (in comments or implicit declarations) are not included beforehand, the user (programmer) must decide which files to include, but handle it simply and adopt a structure that avoids multiple inclusions. Multiple inclusions are the bane of system programming. It is not uncommon for a single C source file to compile with five or more file inclusions. The /usr/include/sys in Unix systems uses this dreadful method.Speaking of #ifdef, there is a small anecdote: while it can prevent reading files twice, it is often misused. #ifdef is defined in the file itself, not in the file that includes it. As a result, it often leads to thousands of unnecessary lines of code passing through the lexical analyzer, which is the most time-consuming phase in excellent compilers.Simply following the above simple rules can make your code elegant and beautiful, at least pleasing to the eye, turning technology into art~~
Further Reading
Some believe that now is the era of Java and .NET, and who still needs C and assembly? Little do they know that Java and .NET are built on software, established to monopolize the market, like digging a golden pit for you to jump into, while you think you are standing on the shoulders of giants, but in fact, you have become a frog at the bottom of the pit. To become a true programmer and aspire to be a master, one must start from the machine, from the CPU to the operating system, and then to the software system. The realm of mastery is like a clear mirror after enlightenment; software design becomes magical, I am the program, and the program is me.Observer Li Si says: This person is foolish! I can drag a few controls with a mouse and create an xxx management system; you might not be able to write it in C language even in a year! Well, I must admit that those who say this have already become slaves of MS. I do not know much about it, but MFC itself is a closed architecture. Learning from MFC will only form a closed mindset because MS wants many people to only learn the surface things and not become masters, so it strongly recommends so-called visual programming development tools, and many people are willing to fall for it, ultimately losing their direction. Saying he cannot program is also possible, but if the program is a bit complex, when problems arise, he will not be able to figure out where the problem is, anyway, it will be unclear!Liang Zhaoxin, a big shot, said: “I just don’t understand, how can you write programs with a mouse? In my company, the masters’ keyboards are clattering away, while the mouse occasionally clicks; the novices’ mice are clicking away, while their keyboards are rarely touched, and their salaries differ by more than just a factor of one!”C language is the foundation of major operating systems; Unix, Linux, and Windows are all developed in C language (some parts are mixed with assembly language). Don’t you see that Windows API is the interface of C language functions? Most applications in Unix/Linux are developed in C language; Windows applications are no longer developed purely with APIs, most rely on some Application Framework, such as the so-called VC++, which actually refers to VCIDE + C++ language + MFC (now the focus has shifted to ATL, WTL), but low-level software such as Windows services, networks, and drivers are still developed in C language. Various language compilers, including the Java virtual machine, are developed in C language. Various embedded devices, such as mobile phones and PDAs, are also developed in C language.Here are some personal suggestions:
- Read more textbooks and code
Due to the flexibility and power of C language, it is very challenging for beginners to master it comprehensively. Therefore, during the learning process of C language, one should read textbooks and code extensively; if something is not in the textbook, you can search online. First, you must master variables, constants, basic data types, library functions and their characteristics and applications, operators, expressions, and statements, as well as the basic format of writing C language. Next, you should master the control statements, arrays, functions, pointers, and other foundational knowledge of C language. Once you are proficient in the above knowledge, you can learn about linked lists, queues, trees, graphs, and so on. Finally, you should be proficient in the application of each knowledge point, focusing on key issues such as function design frameworks, parameter design, and return value design.
- Learn mathematics and English well
In the process of learning C language, there are generally a lot of algorithms and data structures to understand (freshmen will encounter this knowledge in their sophomore year; if there are students who want to understand it in advance, you can click the link below to view it). Many arithmetic operations, logical operations, relational operations, and loop structures can be completed using mathematical knowledge. Similarly, many algorithms are designed to perform calculations in the field of mathematics. Writing programs is to enable computers to replace humans in the operation process, thereby reducing manpower. It can be seen that mathematics holds an important position in computer learning. With mathematical knowledge, you will find that data structures and algorithms are actually quite simple. Similarly, in the process of learning C language, we will use a lot of English knowledge. For programming, the role of English lies in reading English documents and adapting to an international programming environment. We need to remember some commonly used vocabulary in C language, which are many keywords.
- Connect theory with practice, emphasize hands-on experiments
Most courses in computer science are tested through practice to verify learning outcomes. More importantly, all theoretical knowledge learned must be better utilized in practice. Programming is a practical job; it is not enough to just talk without practice. When you first start learning, you can practice the exercises in the book more. For areas you do not understand, writing a small program to experiment is the best method, as it can leave a deep impression on you. During the process of hands-on work, you should continuously correct your bad programming habits and misconceptions. C language is also a very practical course; you must master concepts and also write programs, debug, and run them. Develop the habit of analyzing problems before going to the computer and writing the program source code. Pay attention to the format, punctuation, etc., of the program while debugging; be patient, as sometimes a program may need to be modified multiple times, and even after much effort, there may still be no results. You should continuously consult teachers or classmates and keep checking materials, so programming should never be abandoned when faced with difficulties. This is the key moment to improve your level; you must persist. Everyone should have confidence in themselves and confidence in mastering the C language course, so that we can have a good learning state and correct bugs. After successfully debugging the program, summarize and analyze the shortcomings that occurred during the program writing process and the issues to pay attention to in future problem-solving processes. After successfully debugging the program, you should complete the experiment report and gradually accumulate debugging experience. Cultivate good programming habits.
- Develop good programming habits
(1) There should be comments after complex code. If there is just a pile of code, others will not be able to understand your code, and it is not conducive to finding errors. Unless you are always writing things for yourself. What can be explained in the code should definitely be reflected in the code. For example, variable names, function names, try to indicate what they are used for when naming.(2) Pay attention to not making statements too long; try to keep the main function short. It is often seen that others’ code has a main function of only a few lines, with several function calls, while definitions are all outside the main function. This reduces nesting within the main function and makes it more concise and easier to read.(3) Pay attention to the choice of statements. It is not that a branch statement must use if, and a loop must use while or for. In appropriate situations, switch and do-while statements should also be used. Sometimes, switch statements are more concise and clear than if statements, while do-while has one less loop than while.
So how to learn microcontroller C language well?
Many people who want to learn microcontrollers ask me the first question: how can I learn microcontrollers well? Today, I will talk about how I started learning microcontrollers, how I got started, and how I became proficient.First, let’s talk about microcontrollers. Generally, the MCS-51 microcontroller is commonly used now; it has a lot of materials, many users, and a large market. Based on my personal experience, here’s how to learn microcontrollers faster. The microcontroller course is a subject that emphasizes hands-on practice; you cannot just read books. However, learning it must start with reading books because you need to understand the various functional registers of the microcontroller. To put it simply, using a microcontroller means using software to control the various functional registers of the microcontroller. To clarify, it is about controlling when the voltage levels of the microcontroller pins output high or low. The changes in these high and low levels control your system board to achieve the various functions we need. As for reading books, you only need to have a general understanding of what each pin of the microcontroller does and what functions it can achieve. The first and second times you may not understand, but that’s okay because you still lack practical sensory experience. Therefore, I always say that reading books about microcontrollers for two or three days is enough. You can read five or six novels in a day, but you can read a microcontroller book two or three times in two or three days without needing to read it carefully. I recommend one book, and this one is enough: “New MCS-51 Microcontroller Application Design,” published by Harbin Institute of Technology Press, authored by Zhang Yigang. Get a general understanding of the content in the book, and then practice, which is crucial. If you say you cannot learn microcontrollers without practice, that is impossible. Regarding practice, you can choose two methods: one method is to buy a microcontroller learning board yourself, which does not require too many functions. For beginners, buying a board with too many functions is unnecessary; you will never use many of the features in your lifetime. I suggest having a running light, a digital tube, an independent keyboard, a matrix keyboard, AD or DA (the principle is the same), a liquid crystal display, and a buzzer; that’s about it. If you can skillfully apply the items I mentioned above, you can say you have entered the hardware aspect of microcontrollers. The rest is to practice designing circuits and continuously accumulate experience. Once you pass the first hurdle, the subsequent path will be much easier; the beginning is always the hardest, as everyone may have heard. The second method is to seek help from someone skilled in microcontrollers around you to help you set up a simple minimum system board. For experts, making a microcontroller minimum system board only takes a minute, while it is much more difficult for beginners because only by understanding the hardware can you use it skillfully. If you do not have such an expert around you and cannot find someone to help you, I advise you to buy one yourself; after all, having one is much more convenient, and you can use it for small experiments related to microcontrollers in the future, saving trouble.Once you have the microcontroller learning board, you should practice more. It is best to have a computer; spend less time watching movies and playing games. Connect the learning board to the computer, open the debugging software, and sit in front of the computer. First, learn how to use the debugging software, then 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 door. You will find how charming microcontrollers are; it’s so fun. This is not just learning knowledge; it’s playing. When the program you write achieves your intentions, you will be happier than doing anything else. You will become addicted, really. People in electronics can indeed become addicted. Then make the digital tube light up; once you master these two items, you will be unable to extricate yourself, and you will start considering which field you want to pursue for the rest of your life. This is how to practice. When writing programs, you will definitely encounter many problems, and at that time, you can flip through books for answers or ask others. When you get answers, you will remember them for a lifetime. Knowledge must be applied to real life to solve practical problems; this is how it can exert its effect. Think about it; after so many years of university, what have you learned in class? Is it just to be busy for the final exam? After the exam, you get a score of 90, and you are so happy, but when the next semester starts, you forget everything. What have you learned? But I tell you, once you learn microcontrollers, you will never forget. Additionally, let me talk about programming with assembly and C language. Many students take C language courses in their first and second years; I have also taken them, and I know that at that time, it was all about multiplying and adding, calculating factorials, etc. After learning, what’s the use? When you need to use C language to program microcontrollers, you will be dumbfounded. The things in the book must be applied. Programming microcontrollers can be done in either C language or assembly language, but I recommend using C language, as it is better. If you already have a foundation in C language, it will be easier to learn; if not, you can learn C language while learning microcontrollers. C language is 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 a hard time 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 code in assembly is efficient, but it is relatively difficult and verbose, especially when encountering algorithmic problems, which can be extremely troublesome. Now, the main frequency of microcontrollers is constantly increasing, and we do not need such high-efficiency code because of the high-frequency clock. The ROM of microcontrollers is also continuously increasing, enough to accommodate any code you write in C language. The materials for C language are abundant and easy to find, and its portability is very good; you only need to change an 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 work, and have a strong will not to give up until you succeed, learning microcontrollers will be a very easy task.Steps:1. Find a book to get a general understanding of the microcontroller structure; just a general understanding is enough. You don’t need to understand everything, and you are not writing a book. (Three days)2. Find a learning board to practice writing programs; learning microcontrollers is about practicing programming. When you encounter something you don’t understand, ask someone or check the book. (Twenty days)3. Search online for some small circuit-related materials to practice designing peripheral circuits. After soldering, debug it yourself and familiarize yourself with the process. (Ten days)4. Completely design circuits and products with your personal style… you will have become an expert…Did you see that? With a little over a month of effort, you can become an expert. I will say no more; whether you can learn it well and whether you can put in the effort depends on you.My Learning Insights on MicrocontrollersMany people say that it is best to learn assembly language before learning microcontrollers. From my experience, I can tell everyone that there is absolutely no need for this. Beginners can directly use C language to program microcontrollers from the start, which saves time, is easier to learn, and will lead to rapid progress. When first learning microcontrollers, do not waste time understanding the internal structure of the microcontroller; this will only undermine your confidence. Once you learn programming, you will naturally master its internal structure step by step.Practice in Learning MicrocontrollersImprovement in microcontrollers relies heavily on practice. To learn microcontrollers well, software programming is indispensable. However, familiarizing oneself with hardware is also very important for mastering microcontrollers. How to learn hardware well? Hands-on practice is essential. We can improve our understanding and proficiency with certain chips by making our own electronic projects. This way, we can gain more insight into the structure of the chips. I believe that once you complete an electronic project of your own, your level in microcontrollers will undergo a qualitative improvement.Using microcontrollers means understanding the hardware structure of microcontrollers and applying internal resources, learning various functional initialization settings in assembly or C language, and programming to achieve various functions.Step 1: Using Digital I/OUsing button input signals and LED displays to show output levels can help learn the digital I/O functions of pins. When a button is pressed, an LED lights up; this demonstrates the function of combinational logic in digital circuits. Although it is very simple, it can teach general programming ideas for microcontrollers, such as the need to set many registers to initialize pins to enable digital input and output functions. Each time a function of the microcontroller is used, the registers controlling that function must be set; this is a characteristic of microcontroller programming. Do not be afraid of the trouble; all microcontrollers work this way.Step 2: Using TimersLearning to use timers allows the microcontroller to implement sequential circuits. Sequential circuits have powerful functions and are widely used in industrial and household electrical device control. For example, a microcontroller can implement a corridor light switch with one button, which turns on the light for three minutes after pressing the button once, keeps the light on continuously after pressing the button twice, and turns off the light if the button is pressed for more than 2 seconds. 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 3: InterruptsThe 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 occurrences, such as the falling edge of a button press. To enable the microcontroller to respond to rapid actions during normal program operation, it is necessary to use the interrupt function of the microcontroller. This function interrupts the normal running program 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 that can monitor one thing while doing another. Once the monitored event occurs, it interrupts the current task to handle the monitored event. Of course, multiple events can be monitored. A vivid metaphor is that the interrupt function allows the microcontroller to eat from the bowl while watching the pot.Once you master these three steps, it is equivalent to mastering three of the eighteen dragon-subduing palms; you can barely protect yourself.Step 4: Communicating with PC via RS232Microcontrollers 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 for the PC’s RS232 interface, and so on. Imagine how interesting it would be if the data displayed on the microcontroller experiment board appears on the PC monitor, and the keyboard signals from the PC can be displayed on the microcontroller experiment board!Step 5: Learning A/D ConversionThe MAP430 microcontroller has a multi-channel 12-bit A/D converter, which allows the microcontroller to operate on analog quantities, 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 6: Learning PCI, I2C Interfaces, and LCD InterfacesLearning to use these interfaces can make it easier for the microcontroller to connect to external devices, which is very important for expanding the functions of the microcontroller.Step 7: Learning Comparison, Capture, and PWM FunctionsThese functions enable the microcontroller to control motors, detect speed signals, and implement motor speed controllers. If you master the above seven steps, you can design general application systems, equivalent to learning ten moves of the eighteen dragon-subduing palms, and can attack.Step 8: Learning USB Interfaces, TCP/IP Interfaces, and Hardware and Software Design of Various Industrial BusesLearning USB interfaces, TCP/IP interfaces, and hardware and software design of various industrial buses is very important because this is the development direction of current product development.By this point, it is equivalent to mastering fifteen moves of the eighteen dragon-subduing palms, but you are still not at the level of being invincible in the world. Even so, you can be considered a microcontroller expert!


Screenshots of Some Electronic Books

【Complete Set of Hardware Learning Materials Collection】
