10 Microcontroller Programming Application Tips Summary


1. What Are the Advantages and Disadvantages of C Language Programming and Assembly Language in Microcontroller Development?


Answer: Assembly language is a symbolic language that uses mnemonics to represent machine instructions, making it the closest language to machine code. Its main advantages are low resource usage and high execution efficiency. However, different CPUs may have variations in their assembly languages, making it difficult to port.


C language programming is a structured high-level language. Its advantages include good readability and easy portability, making it a widely used programming language. The disadvantages are that it consumes more resources and its execution efficiency is not as high as that of assembly language.


For the currently widely used RISC architecture 8-bit MCUs, the internal ROM, RAM, and STACK resources are limited. If C language is used for programming, one C language instruction may compile into many machine code instructions, easily leading to issues like insufficient ROM space and stack overflow. Moreover, some microcontroller manufacturers may not provide C compilers. In contrast, assembly language has one instruction corresponding to one machine code, making each action clear and easy to control regarding program size and stack usage, thus simplifying debugging. Therefore, we recommend using assembly language for microcontroller development.


If you are interested in C language programming for microcontrollers, HOLTEK provides C compilers for their microcontrollers.


2. Can C++ Be Used for Microcontroller Programming, Along with C and Assembly Language?


Answer: In microcontroller programming development, the main languages used are assembly and C, with no use of C++.


3. Is It Necessary to Know C When Developing Microcontroller Programming?


Answer: Assembly language is a symbolic language that uses mnemonics to represent machine instructions, making it the closest language to machine code. Its main advantages are low resource usage and high execution efficiency. However, different CPUs may have variations in their assembly languages, making it difficult to port.


For the currently widely used RISC architecture 8-bit MCUs, the internal ROM, RAM, and STACK resources are limited. Using C language programming, one C language instruction may compile into many machine code instructions, easily leading to issues like insufficient ROM space and stack overflow. Moreover, some microcontroller manufacturers may not provide C compilers. In contrast, assembly language has one instruction corresponding to one machine code, making each action clear and easy to control regarding program size and stack usage, thus simplifying debugging. Therefore, we recommend using assembly language for resource-constrained microcontroller development.


C language is a compiled programming language that combines features from various high-level languages while possessing the functionalities of assembly language. C language programming offers a rich set of library functions, fast computation speed, high compilation efficiency, good portability, and direct control over system hardware. C programming is a structured programming language that supports the top-down structured programming technique widely adopted in current programming.


Additionally, C language programs have a well-structured modular program design, providing strong support for modular programming methods in software development. Therefore, using C language programming for system software development has become a mainstream approach, significantly shortening development cycles and enhancing software readability, making it easier to improve and expand, thus leading to larger and more complete systems.


In summary, using C language for microcontroller programming design is an inevitable trend in microcontroller development and application. Therefore, as a microcontroller developer involved in comprehensive and large-scale software system development, it is best to master basic C language programming.


4. For a Complex Project with a Short Development Time, Is It Better to Use C or Assembly Language?


Answer: For complex projects with tight development timelines, C language can be used, but the prerequisite is to be very familiar with the MCU system’s C language and C compiler, especially the data types and algorithms supported by that C compilation system. Although C language is the most common high-level language, different MCU manufacturers have differences in their C language compilation systems, especially in the operation of some special function modules. If these characteristics are not understood, debugging can become troublesome, and it may end up being faster to use assembly language.


5. Where Can I Find Textbooks or Materials on 8088 and 196 Microcontroller Textbooks for Teaching?


Answer: A commonly used textbook on this subject in universities is “IBM-PC Assembly Language Programming” published by Tsinghua University Press, which can be found both online and in bookstores. Additionally, many other textbooks can be found online, such as “Microcomputer Principles and Assembly Language Tutorial” (by Yang Yanshuang, Zhang Xiaodong, et al.) and “16/32 Bit Microcomputer Principles, Assembly Language, and Interface Technology” (by Zhong Xiaojie, Chen Tao, published by Machinery Industry Press), which can be checked in larger technology bookstores or ordered directly online.


6. Should Beginners Learn C or Assembly Language First?


Answer: For beginners in microcontroller programming, it is recommended to start with assembly language. This is because assembly language is the closest language to machine code, which can deepen beginners’ understanding of various functional modules of the microcontroller, thus laying a solid foundation.


7. I Am a Third-Year Student at Wuhan University of Electronic Science and Technology, Having Studied Electronic Circuits, Digital Logic, Assembly, and Interfaces, and C Language, but I Always Feel Confused and Think I Don’t Know Anything. What Should I Do?


Answer: The university process is primarily theoretical, and there are fewer practical opportunities, which often leads to a disconnect between theory and practice, a common issue in the domestic university education system. However, students should not aim too high. Generally, starting from the third year, students will begin to encounter specialized courses, and electronics-related majors will offer relevant microcontroller application courses along with simple experimental projects. Therefore, it is essential to seize opportunities in lab classes and practice hands-on operations frequently. It is also helpful to read related electronic technology magazines and websites to learn about others’ development experiences and hardware design solutions. If possible, participating in electronic design competitions can also be beneficial, as collaborating with 2-3 people to create a complete system can provide more help. During the senior project phase, choosing related topics to work on practical cases can also enhance experience. Gaining experience is a gradual process, and one should proceed step by step.


8. How Can Students Learn Microcontroller Programming Effectively?


Answer: To learn microcontrollers well, the most important thing is practice, gaining experience through practical work. For students, there are indeed fewer practical opportunities, but if possible, they can choose related topics for graduation internships to engage in actual projects. If microcontroller principles are a core course, the school will likely arrange more practical hands-on opportunities. If capable, finding related part-time jobs can also be beneficial. Moreover, microcontroller development applications require a combination of software and hardware, so one should not only focus on perfecting programming skills but also accumulate hardware knowledge. Regularly visiting electronic forums, buying related magazines, and if possible, purchasing small components to build a small system can be very helpful.


9. How Can I Become a Microcontroller Programming Expert?


Answer: To become an expert in microcontroller programming, one should practice frequently and stay updated on microcontroller development trends. Regularly visiting related websites can provide a wealth of useful information.


10. Is Software Programming in the Microcontroller Industry Suitable for Women?


Answer: It depends on personal interest and patience for software programming; both men and women are suitable for this industry.

Leave a Comment