1. What are the advantages and disadvantages of C language and assembly language in microcontroller development?
Answer: Assembly language is a symbolic language that uses mnemonic words to represent machine instructions, making it the closest language to machine code. Its main advantages are low resource usage and high execution efficiency. However, assembly languages may differ among different CPUs, making them less portable.
C language 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 has lower execution efficiency than assembly language.
For the commonly used RISC architecture 8-bit MCUs, the internal ROM, RAM, and STACK resources are limited. If C language is used, one C instruction can compile into many machine codes, easily leading to issues like insufficient ROM space and stack overflow. Additionally, some microcontroller manufacturers may not provide C compilers. In contrast, with assembly language, one instruction corresponds to one machine code, making the actions executed clear, and it is easier to control program size and stack calls, making debugging more convenient. Therefore, we still recommend using assembly language for microcontroller development.
If you are interested in C language for microcontrollers, HOLTEK provides a C compiler that can be downloaded for free from their website.
2. Can C++ be used for microcontroller development, given that C and assembly are the main languages?
Answer: In microcontroller development, the main languages used are assembly and C; C++ is not commonly used.
3. Is it necessary to know C language for microcontroller development?
Answer: Assembly language is a symbolic language that uses mnemonic words to represent machine instructions, making it the closest language to machine code. Its main advantages are low resource usage and high execution efficiency. However, assembly languages may differ among different CPUs, making them less portable.
For the commonly used RISC architecture 8-bit MCUs, the internal ROM, RAM, and STACK resources are limited. If C language is used, one C instruction can compile into many machine codes, easily leading to issues like insufficient ROM space and stack overflow. Additionally, some microcontroller manufacturers may not provide C compilers. In contrast, with assembly language, one instruction corresponds to one machine code, making the actions executed clear, and it is easier to control program size and stack calls, making debugging more convenient. Therefore, we still recommend using assembly language for resource-limited microcontroller development.
Meanwhile, C language is a compiled programming language that incorporates features from various high-level languages while also possessing the functionality of assembly language. C language has rich library functions, fast operation speed, high compilation efficiency, and good portability, allowing direct control over system hardware. It is a structured programming language that supports the top-down structured programming techniques widely used in current programming. Furthermore, C language programs have a well-structured modular program structure, providing strong support for adopting modular programming methods in software development. Thus, using C language for program design has become a mainstream practice in software development. Writing system software in C language can significantly shorten the development cycle and noticeably increase software readability, facilitating improvements and expansions, leading to the development of larger and more complete systems.
In summary, using C language for microcontroller programming is an inevitable trend in microcontroller development and application. Therefore, it is best for a microcontroller developer who is well-rounded and involved in large-scale software system development to master basic C programming.
4. For a complex project with a short development time, should C or assembly be used?
Answer: For complex projects with tight development timelines, C language can be used, provided that the developer is very familiar with the MCU system’s C language and C compiler, especially regarding the data types and algorithms supported by the C compilation system. Although C language is the most commonly used high-level language, different MCU manufacturers have different C compilation systems, particularly in the operation of special functional modules. If these characteristics are not understood, debugging can become troublesome, and it might ultimately be faster to use assembly.
5. Where can I find textbooks or materials on the 8088 and 196 microcontroller for teaching purposes?
Answer: A commonly used textbook on this topic in universities is “IBM-PC Assembly Language Programming,” published by Tsinghua University Press, which can be found online and in bookstores. Additionally, many other textbooks can be searched online, such as “Microcomputer Principles and Assembly Language Tutorial” (edited by Yang Yanshuang, Zhang Xiaodong, et al.) and “16/32 Bit Microcomputer Principles, Assembly Language, and Interface Technology” (authors: Zhong Xiaojie, Chen Tao, published by the Machinery Industry Press), which can be found in larger technology bookstores or ordered directly online.
6. Should beginners learn C or assembly first?
Answer: For beginners in microcontrollers, it is recommended to start with assembly language. This is because assembly language is the closest to machine code, which can deepen beginners’ understanding of various functional modules of the microcontroller, thereby establishing a solid foundation.
7. As a third-year student in electronic science at Wuhan University, I have studied electronic circuits, digital logic, assembly, and C language, but I often feel confused and think I don’t know anything. What should I do?
Answer: The university experience is primarily theoretical, with fewer practical opportunities, often leading to a disconnect between theory and practice, which is a common issue in domestic university education. However, students should not be overly ambitious. Generally, from the third year, students will start to encounter some specialized courses, and electronics-related majors will offer microcontroller application courses with simple experimental projects. Therefore, it is essential to take full advantage of lab opportunities and engage in hands-on practice. Students can also read relevant electronic technology magazines and websites to learn from others’ development experiences, hardware design solutions, and software design experiences. If possible, participating in electronic design competitions with a group of 2-3 people to create a complete system can be very helpful. During the senior design phase, students can also choose related topics for practical case studies to gain experience. Every endeavor involves an accumulation of experience, and progress should be made step by step.
8. How can students learn microcontrollers effectively?
Answer: To learn microcontrollers effectively, practical experience is crucial. Students may have fewer opportunities for practice while in school, but if possible, they can choose relevant topics for graduation internships to gain exposure to actual projects. Additionally, if microcontroller principles are a core course, the school will likely arrange more practical lab opportunities. If capable, students can seek part-time jobs related to microcontrollers, which would be beneficial. Since microcontroller development applications require a combination of hardware and software, it is essential not only to focus on perfecting programming skills but also to accumulate hardware knowledge. Students should frequently visit electronic forums and websites, purchase related magazines, and if possible, buy small components from electronics markets to build small systems and get them working.
HOLTEK’s microcontroller is an 8-bit microcontroller with a RISC architecture that can be widely used in household appliances, security systems, handheld games, etc. It can be categorized into I/O type microcontrollers, LCD type microcontrollers, A/D type microcontrollers, A/D with LCD type microcontrollers, etc.
9. How can one become an expert in microcontrollers?
Answer: To become an expert in microcontrollers, one should practice more and keep abreast of the latest trends in microcontroller development. Regularly visiting relevant websites can provide access to many useful resources.
10. Is the microcontroller programming industry suitable for women?
Answer: It depends on personal interest and patience for software programming; both men and women are suitable for this industry.
12. How long can 8-bit microcontrollers last?
Answer: Currently, the main focus of MCU products is still in the 8-bit domain, primarily applied in automotive applications, consumer electronics, computers and PC peripherals, telecommunications, office automation, and industrial control. The automotive market is mainly in Europe and the US, while the Asia-Pacific region focuses on consumer electronics, with large quantities and low prices as the mainstream product. At present, there is still a significant price difference between 16-bit and 8-bit MCUs, and new application fields are still being developed. The industry expects that at least by 2005, 8-bit MCUs will still be the mainstream products in the MCU market.
13. Is learning ARM and embedded systems more promising than learning other general microcontrollers? What relevant knowledge should a beginner have?
Answer: Generally, there is a hierarchical difference between 8-bit microcontrollers and ARM-based embedded systems. ARM is suitable for advanced products with higher system complexity, such as PDAs and mobile phones. In contrast, 8-bit microcontrollers have a simple architecture and relatively fewer hardware resources, making them suitable for general industrial control and consumer appliances. For a beginner in microcontroller software programming, it is advisable to start with HOLTEK series or 8051-based 8-bit microcontrollers for practice. Beginners should possess knowledge related to software programming; microcontroller software programming is primarily based on assembly language, with different manufacturers having their own syntax, but most are based on the RISC MCU architecture, where RISC (Reduced Instruction Set Computer) represents all MCU instructions. These are composed of simple instructions optimized for the MCU’s circuitry, thereby improving execution speed. Additionally, beginners should have knowledge of microcontroller I/O interface applications, which involves the use of peripheral circuits and various components, in conjunction with their studies in electronics and circuit theory.
14. What 8-bit microcontrollers conform to the 44PIN of the 80 series?
Answer: The 8-bit microcontrollers conforming to the 44PIN of the 80 series include Z8674312FSC, Z86E2112FSC, Z86E2116FSC.
15. Please introduce the testing methods for MCUs.
Answer: MCUs undergo different testing methods at each stage from production to packaging. There are mainly two types: mid-test and final test.
Mid-test refers to the testing of WAFER, which includes functional verification and AC/DC tests. The projects are quite numerous; for example, the main items for HOLTEK products include:
Continuity testing: Checking whether each I/O pin’s protective diodes function correctly.
Functional testing: Using test patterns provided by the product designer to check if the results match the simulation state.
STANDBY current testing: Measuring the leakage current of each pad when the IC is in HALT mode, ensuring it meets minimum specifications.
Power consumption testing: Measuring the static and dynamic power consumption of the entire IC.
Input voltage testing: Measuring the input voltage response characteristics of each input pin.
Output voltage testing: Measuring the output voltage levels of each output pin.
Related frequency characteristics (AC) testing, which involves applying a certain frequency from the I/O port and checking if the output matches.
To ensure the long-term and stable quality of IC production, reliability tests are also conducted, including ESD testing, LATCH UP testing, temperature cycling testing, high-temperature storage testing, humidity storage testing, etc.
Final testing refers to the testing of packaged products, i.e., PACKAGE testing. This involves testing all products that have passed mid-test after packaging. The method is primarily automatic testing by machines, but the test items remain the same as those in WAFER TEST. The purpose of PACKAGE TEST is to determine whether any damage occurred during the packaging process.
16. Can a microcontroller be used to detect the charging and discharging time of a mobile phone battery and the voltage and current changes during charging and discharging, and display the results on a computer using an I/O port?
Answer: Most smart chargers on the market use MCUs to control charging current and voltage. However, displaying the results on a computer seems impractical; it may only be used in specialized battery testing instruments. For general mobile phone users, who would need to use a computer for display while charging? The simplest way to connect a microcontroller to a computer is through serial communication, requiring an RS-232 chip.
17. How should one approach ARM programming?
Answer: Taking the embedded system perspective as an example, embedded processors can generally be categorized into three types: embedded microprocessors, embedded microcontrollers, and embedded DSP (Digital Signal Processor).
Embedded microprocessors correspond to the CPUs of general-purpose computers. In applications, microprocessors are generally assembled on specially designed circuit boards, retaining only the functions related to embedded systems, meeting the requirements for small size and low power consumption. Current embedded processors mainly include PowerPC, Motorola 68000, ARM series, etc.
Embedded microcontrollers, also known as microcontrollers, integrate the CPU, memory (a small amount of RAM, ROM, or both), and other I/O interfaces into a single integrated circuit. Common examples include the HOLTEK MCU series, Microchip MCU series, and 8051.
Embedded DSP is specifically designed for fast processing calculations of discrete-time signals, improving compilation efficiency and execution speed. DSP is increasingly entering the embedded market in fields such as digital filtering, FFT (Fast Fourier Transform), spectrum analysis, and image processing.
18. In RF control, how does the MCU’s clock (crystal oscillator) and data lines radiate the fundamental frequency or its harmonics, which are then amplified by a low-noise amplifier (LNA) and mixed, resulting in in-band spurs that cannot be filtered out? Besides using layout and selecting low-radiation MCUs, what other methods can reduce this?
Answer: When designing high-frequency circuits, there are many considerations, especially for GHz-level high-frequency circuits, where the lengths of the pads and printed patterns of various electronic components significantly affect circuit characteristics. In recent years, there seems to be an increasing trend of sharing circuit boards between high-frequency and digital circuits, forming mixed-load circuit systems. Such designs often lead to instability in high-frequency circuit operations when digital circuits are active, one reason being that noise generated by digital circuits affects the normal operation of high-frequency circuits. To avoid the aforementioned issues, besides attempting to separate the two circuit blocks, thoroughly reviewing the design concepts before designing the circuit board is essential. Essentially, designing high-frequency circuit boards requires mastery of these techniques.
Some screenshots of electronic books