Classic question and answer about MCU application programming

1. What are the advantages and disadvantages of C language and assembly language when developing microcontroller?

A: Assembly language is a symbolic language that uses text mnemonics to represent machine instructions and is the language closest to machine code. Its main advantages are low resource consumption and high program execution efficiency. However, different CPUs may have different assembly languages, so they are not easy to port.

C language is a structured high-level language. Its advantage is that it is easy to read and easy to transplant. It is a computer language commonly used. The disadvantage is that it takes up more resources and the execution efficiency is not compiled high.

For the 8-bit MCUs that are commonly used in the RISC architecture, the internal ROM, RAM, STACK and other resources are limited. If written in C language, a C language command will become a lot of machine code after compiling, which is easy to appear. Insufficient space, stack overflow, etc. And some microcontroller manufacturers may not be able to provide a C compiler. As for assembly language, an instruction corresponds to a machine code. Every action performed at each step is clear, and the program size and stack call situation are easy to control, and debugging is also convenient. Therefore, in the development of microcontroller, we still recommend the use of assembly language is better.

About the MCU application programming mcu test

2. C or assembly language can be used for single-chip microcomputers, can C++ be used?

A: In the development of single-chip microcomputer, it is mainly assembly and C, without C++.

3. Do you need C to develop MCU?

A: Assembly language is a symbolic language that uses text mnemonics to represent machine instructions and is the language closest to machine code. Its main advantages are low resource consumption and high program execution efficiency. However, different CPUs may have different assembly languages, so they are not easy to port.

For the 8-bit MCUs that are commonly used in the RISC architecture, the internal ROM, RAM, STACK and other resources are limited. If written in C language, a C language command will become a lot of machine code after compiling, which is easy to appear. Insufficient space, stack overflow, etc. And some microcontroller manufacturers may not be able to provide a C compiler. As for assembly language, an instruction corresponds to a machine code. Every action performed at each step is clear, and the program size and stack call situation are easy to control, and debugging is also convenient. Therefore, in the development of less-capacity microcontrollers, we still recommend using assembly language.

The C language is a compiled programming language that takes into account the characteristics of many high-level languages ​​and has the function of assembly language. C language has a rich library function, fast computing speed, high compilation efficiency, good portability, and direct control of system hardware. C language is a structured programming language that supports the top-down structured programming techniques widely used in current programming. In addition, the C language program has a complete modular program structure, which provides a powerful guarantee for the modular programming method in software development. Therefore, programming in C language has become a mainstream in software development. Writing the target system software in C language will greatly shorten the development cycle and significantly increase the readability of the software, facilitate the improvement and expansion, and develop a system with larger scale and better performance.

In summary, the use of C language for microcontroller programming is an inevitable trend in the development and application of microcontrollers. Therefore, as a technology-intensive and involved in the development of large-scale software systems, microcontroller developers should be able to master basic C programming.

4. When developing a more complex project with a short development time, is C still developed with assembly?

A: For complex and time-critical projects, you can use the C language, but only if you are familiar with the C language and C compiler of the MCU system, especially the data types and algorithms that the C compiler system can support. . Although C language is the most common high-level language, different CCU manufacturers have different C language compilation systems, especially in the operation of some special function modules. If you don't understand these features, then it will be annoying to debug. In the end, it may not be as fast as assembly.

5. In the teaching, 8088 and 196 chip MCU teaching materials should be used. Can you find books or materials about this?

A: A textbook commonly used in this field is published in the "IBM-PC assembly language programming" by Tsinghua University Press. It can be found online and in bookstores. In addition, many other online searches are available. materials such as: "computer Architecture and Assembly language tutorial" (double Zhang Xiaodong Yang Yan, eds) and "16/32 bit microcomputer principle, assembly language and interface technology" (author: Zhong Xiaojie Chen Tao, mechanical industry Publishing House), etc., can be larger Find in the tech bookstore or order directly from the internet.

6. Should beginners learn C or assemble first?

A: For beginners of MCU, it should be learned from assembly. Because assembly language is the language closest to machine code, it can deepen the understanding of beginners on each function module of MCU, so as to lay a solid foundation.

7. I am a student of Electronic Science and Technology University of Wuhan University. I have learned electronic circuits, digital logic, assembly and interface, and C language, but I always feel confused. I don’t think I can do anything. How to do?

A: The university process is a theoretical process. There are fewer opportunities for practice. It often leads to a disconnect between theory and practice. This is a common problem in the domestic university education system, but it must not be high for students. Generally speaking, from the junior high school, some professional courses will be contacted. The electronic related majors will open relevant MCU application courses and there will be simple experimental projects. Then, we must fully grasp the opportunities of the experimental courses, and actually practice the exercises in many places. You can usually look at the relevant electronic technology magazine website to see other people's development experience, hardware design and other software design experience. If possible, you can also participate in some electronic design competitions, and it will be more helpful to take the opportunity to work together as a complete system for 2--3 people. At the graduation stage of the senior year, you can also choose relevant topics to make some practical case growth experience. Everything has a process of accumulation of experience, step by step.

Video Stabilizer

SHAOXING COLORBEE PLASTIC CO.,LTD , https://www.colorbeephoto.com

Posted on