Many questions about single chip microcomputer

Publisher:SereneHarmonyLatest update time:2015-11-09 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. What are the advantages and disadvantages of C language and assembly language when developing microcontrollers?
 
    Answer: Assembly language is a symbolic language that uses mnemonics to represent machine instructions. It is the language closest to machine code. Its main advantages are that it takes up less resources and has high program execution efficiency. However, different CPUs may have different assembly languages, so it is not easy to port.
     C language is a structured high-level language. Its advantages are good readability and easy porting, and it is a widely used computer language. Its disadvantages are that it takes up more resources and its execution efficiency is not as high as assembly language.
     For the 8-bit MCU with RISC architecture that is currently widely used, its internal ROM, RAM, STACK and other resources are limited. If it is written in C language, a C language instruction will become many machine codes after compilation, which may easily cause problems such as insufficient ROM space and stack overflow. In addition, some microcontroller manufacturers may not be able to provide C compilers. In assembly language, one instruction corresponds to one machine code, and it is very clear what action is performed at each step. In addition, the program size and stack call status are easy to control, and debugging is also more convenient. Therefore, in the development of microcontrollers, we still recommend the use of assembly language.
    If you are interested in the C language for microcontrollers, HOLTEK's microcontrollers provide a C compiler, which can be downloaded and used for free from HOLTEK's website (www.holtek.com.cn).
 
2. C or assembly language can be used for microcontrollers, can C++?
 
Answer: In microcontroller development, assembly and C are mainly used, and C++ is not used.
 
3. Do I need to know C to develop microcontrollers?
 
   Answer: Assembly language is a symbolic language that uses mnemonics to represent machine instructions. It is the language closest to machine code. Its main advantages are that it takes up less resources and has high program execution efficiency. However, different CPUs may have different assembly languages, so it is not easy to port.
    For the 8-bit MCU with RISC architecture that is currently widely used, its internal ROM, RAM, STACK and other resources are limited. If it is written in C language, a C language instruction will become many machine codes after compilation, which may easily cause problems such as insufficient ROM space and stack overflow. In addition, some microcontroller manufacturers may not be able to provide C compilers. In assembly language, one instruction corresponds to one machine code, and it is clear what action is performed at each step. In addition, the program size and stack call status are easy to control, and debugging is also more convenient. Therefore, in the development of microcontrollers with fewer resources, we still recommend the use of assembly language.
    C language is a compiled programming language that takes into account the characteristics of multiple high-level languages ​​and has the functions of assembly language. C language has rich library functions, fast computing speed, high compilation efficiency, good portability, and can directly control system hardware. C language is a structured programming language that supports the top-down structured programming technology widely used in current programming. In addition, C language programs have a complete module program structure, which provides a strong guarantee for the use of modular programming methods in software development. Therefore, using C language for programming has become a mainstream in software development. Using C language to write target system software will greatly shorten the development cycle, significantly increase the readability of the software, and facilitate improvement and expansion, thereby developing a larger system with more complete performance.
    In summary, using C language for MCU programming is an inevitable trend in MCU development and application. Therefore, as a MCU developer who has comprehensive technology and is involved in large-scale software system development, it is best to master basic C language programming.
 
4. When developing a complex project with a short development time, is it better to use C or assembly?
 
    A: For complex projects with tight development time, you can use C language, but the prerequisite is that you are very familiar with the C language and C compiler of the MCU system, and pay special attention to the data types and algorithms that the C compiler system can support. Although C language is the most common high-level language, different MCU manufacturers have different C language compiler systems, especially in the operation of some special function modules. If you don't understand these features, it will be troublesome to debug, and in the end it may not be as fast as using assembly.
 
5. In teaching, I need to use 8088 and 196 chip microcomputer teaching materials. Where can I find books or materials on this subject?
 
    Answer: Regarding the textbooks on this subject, a commonly used one in universities is "IBM-PC Assembly Language Programming" published by Tsinghua University Press, which can be found on the Internet and in bookstores. In addition, many other textbooks can be searched on the Internet, such as: "Microcomputer Principles and Assembly Language Tutorial" (edited by Yang Yanshuang, Zhang Xiaodong, etc.) and "16/32-bit Microcomputer Principles, Assembly Language and Interface Technology" (author: Zhong Xiaojie and Chen Tao, published by Machinery Industry Press), etc. You can find them in larger science and technology bookstores or order them directly from the Internet.
 
6. Should beginners learn C or assembly first?
 
   Answer: For MCU beginners, they should start with assembly language, because assembly language is the language closest to machine code, which can deepen the beginners' understanding of each functional module of MCU and lay a solid foundation.
 
7. I am a junior student. I have learned electronic circuits, digital logic, assembly and interface, and C language, but I always feel confused and I don’t know anything. What should I do?
 
    Answer: The university process is a theoretical process, and there are relatively few opportunities for practice, which often causes a disconnect between theory and practice. This is a common problem in the domestic university education system, but students must not aim too high. Generally, you will start to get in touch with some professional courses from the third year of college. Electronic-related majors will offer related single-chip microcomputer application courses and simple experimental projects. You must fully grasp the opportunities of experimental classes and practice more on the actual machine operation. You can usually read more related electronic technology magazine websites to see other people's development experience, hardware design solutions and other people's software design experience. If possible, you can also participate in some electronic design competitions. Taking this opportunity, 2-3 people will work together to make a complete system, which will be more helpful. When you reach the senior year graduation design stage, you can also choose related topics to do some actual cases to increase your experience. There is a process of accumulating experience in everything you do, step by step.
 
8. As a student, how can I learn microcontrollers well?
 
    Answer: The most important thing to learn MCU is practice, and to gain experience in practice. For students in school, there are indeed fewer opportunities for practice, but if there is an opportunity, you can choose related topics for graduation internship, so that you can get in touch with actual projects. And if the principle of MCU is a main course, I believe the school will arrange more opportunities for practice. If you have the ability, you can find some related part-time jobs, which will be more helpful. Moreover, the development and application of MCU requires the combination of software and hardware, so you can't just be satisfied with how perfect the programming skills are. You should also pay attention to the accumulation of hardware knowledge, go to electronic forum websites more often, and buy some related magazines. If possible, you can go to the electronics market to buy some small parts and build a small system to make it work.
    HOTLEK's MCU is an 8-bit RISC-structured MCU, which can be widely used in household appliances, security systems, handheld games, etc. Generally speaking, it can be divided into I/O type MCU, LCD type MCU, A/D type MCU, A/D with LCD type MCU, etc. We have made the Chinese information of these MCUs public on the HOLTEK website www.holtek.com.cn.
     Download address of user manuals for various HOLTEK microcontrollers:
     http://www.holtek.com.cn/referanc/htk_book.htm
    
 
     HOLTEK MCU software/hardware application examples download address:
     http://www.holtek.com.cn/tech/appnote/appnote.htm
 
 HOLTEK MCU support tool download address:
     http://www.holtek.com.cn/tech/tool/tool.htm 
 
 
 
9. How can one become a master of microcontrollers?
 
   Answer: To become a microcontroller expert, you should practice more, always pay attention to the development trends of microcontrollers; often visit some related websites, where you can find a lot of useful information.
 
10. Are women suitable for the microcontroller software programming industry?
 
Answer: It depends on your interests and your patience for software programming. Both men and women are suitable for this industry.
 
11. Where can I download Holtek's data sheet?
 
   A: If you are interested in Holtek's IC, you can go to the website http://www.holtek.com.cn/products/index.htm to select IC data to download.
 
12. How long can 8-bit machines last!
 
    Answer: At present, the main MCU products are still in the 8-bit field, mainly used in six major markets including automotive applications, consumer electronics, computers and PC peripherals, telecommunications and communications, office automation, and industrial control. Among them, the automotive market is mostly in Europe and the United States, while the Asia-Pacific region is dominated by consumer electronics, and large quantities and low unit prices are the mainstream products. At present, there is still a considerable price difference between 16-bit MCUs and 8-bit products, and new application fields are still being developed. The industry predicts that 8-bit MCUs will still be the mainstream MCU products at least before 2005.
 
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 difference in the level of embedded systems between 8-bit MCU and ARM. ARM is suitable for advanced products with greater system complexity, such as PDA, mobile phones and other applications. 8-bit MCU is suitable for general industrial control, consumer home appliances, etc. due to its simple architecture and relatively few hardware resources. For a beginner in software programming of MCU, HOLTEK series or 8051 and other 8-bit MCUs should be used for introductory exercises. Beginners should have relevant knowledge of software programming. The general software programming of MCU is based on assembly language. Each company has its own syntax, but most of them are based on RISC MCU architecture, in which RISC (Reduced Instruction Set Computer) represents all instructions of MCU. They are all composed of some simple instructions. Simple instructions represent that the circuit of MCU can be optimized as much as possible to improve the execution rate. In addition, beginners should have application knowledge of MCU I/O interface, which depends on the use of peripheral application circuits and various components, and must be combined with the electronics and circuits they have learned.
 
14. What are the 80 series 8-bit MCUs that conform to 44PIN?
 
Answer: The 80 series 8-bit microcontrollers that conform to 44PIN are Z8674312FSC, Z86E2112FSC, and Z86E2116FSC.
 
15. Please introduce the testing methods of MCU. Answer: There are different testing methods for each stage of MCU from production to packaging and shipment, and there are mainly two types: intermediate test and final test.
 
    The so-called intermediate test is the test of WAFER, which includes product function verification and AC and DC tests. There are many items, and the main items are as follows, taking HOLTEK products as an example:
 
l Continuity test: Check whether the protection diode connected to each I/O pin is functioning properly.
 
l Functional test: Fill the IC with the test data (TEST PATTERN) provided by the product designer to check whether the result is the same as the status during simulation.
 
l STANDBY current test: Measure whether the leakage current of each contact (PAD) when the IC is in HALT mode remains unchanged in state 1, state 0 or state Z and meets the minimum specification.
 
l Power consumption test: static power consumption and dynamic power consumption of the entire IC.
 
l Input voltage test: Measure the input voltage response characteristics of each input pin.
 
l Output voltage test: Measure the output voltage level of each output pin.
 
l The relevant frequency characteristic (AC) test is also to test whether the output matches the frequency by inputting a certain frequency from the I/O port.
 
l In order to ensure the long-term and stable quality of IC production, product reliability tests will also be performed. These tests include ESD testing, LATCH UP testing, temperature cycle testing, high temperature storage testing, humidity storage testing, etc.
 
    Final test is the test after the product is packaged, that is, PACKAGE test. That is, all products that have passed the intermediate test are tested after packaging. The method is mainly automatic testing of the machine, but the test items are still the same as WAFER TEST. The purpose of PACKAGE TEST is to determine whether the IC has any damage during the packaging process.
 
16. Can a single chip be used to detect the charge and discharge time of a mobile phone battery and the changes in voltage and current during charge and discharge, and can an I/O port be used to display the test results on a computer?
 
A: Most of the smart chargers on the market use MCU to control the charging current and voltage. As for displaying on a computer, it seems not practical, and it may only be used in some special battery testing instruments; for ordinary mobile phone users, who would need a computer to display when charging? To achieve the connection between the microcontroller and the computer, the simplest way is to use serial communication, but you need to add an RS-232 chip
 
17. What about ARM programming?
 
    Answer: Taking the concept of embedded systems as an example, general embedded processors can be divided into three categories: embedded microprocessors, embedded microcontrollers, and embedded DSPs (Digital Signal Processors).
 
    An embedded microprocessor is a CPU that corresponds to a general-purpose computer microprocessor. In applications, the microprocessor is usually mounted on a specially designed circuit board, and only embedded-related functions are retained on the motherboard, which can meet the requirements of small size and low power consumption of embedded systems. Current embedded processors mainly include: PowerPC, Motorola 68000, ARM series, etc.
 
    Embedded microcontrollers are also called single-chip microcomputers. They package CPU, memory (a small amount of RAM, ROM or both) and other interface I/O in the same integrated circuit. Common ones include HOLTEK MCU series, Microchip MCU series and 8051.
 
    Embedded DSP is specially used to process discrete time signals very quickly, improving compilation efficiency and execution speed. In the fields of digital filtering, FFT (Fast Fourier Transform), spectrum analysis, image processing analysis, etc., DSP is entering the embedded market in large numbers.
 
18. When the MCU is in RF control, the clock (crystal oscillator) and data line of the MCU will radiate the base frequency or the multiple of the base frequency, which will be amplified by the low noise amplifier (LNA) and enter the mixing frequency, resulting in in-band Spur, which cannot be filtered out. In addition to using layout and choosing low-radiation MCU to reduce it, are there any other methods?
 
A: There are many things to pay attention to when designing PCBs for high-frequency circuits, especially for GHz-level high-frequency circuits. It is even more important to pay attention to the impact of the length of each electronic component pad and printed pattern on the circuit characteristics. In recent years, there seems to be an increasing trend of high-frequency circuits and digital circuits sharing the same PCB to form the so-called mixed circuit system. Such designs often cause the high-frequency circuit to become unstable when the digital circuit is in operation. One of the reasons is that the noise generated by the digital circuit affects the normal operation of the high-frequency circuit. In order to avoid the above problems, in addition to trying to split the two circuit blocks, it is the fundamental method to fully review the design concept before designing the PCB. Basically, the following three principles must be mastered when designing PCBs for high-frequency circuits:
 
l High quality.
 
l Don’t take shortcuts.
 
l Don’t rush to save time.
 
Here are some suggestions for designing high-frequency circuit boards:
 
    (1) The length of the printed pattern will affect the circuit characteristics. In particular, for transmission lines of high-speed digital circuits with transmission speeds of GHz, strip lines are usually used, and the transmission delay time is corrected by adjusting the wiring length. In fact, this also means that the location of the electronic components has an absolute influence on the circuit characteristics.
 
    (2) Ground is better. The ground layer is set on the entire copper foil surface, and the better ground connected to the via is a common feature of high-frequency circuit boards and high-speed digital circuit boards. In addition, high-frequency circuit boards are most taboo to use narrow printing patterns to depict ground.
 
    (3) The ground terminal of the electronic component is connected to the ground of the circuit board with the shortest length. The specific method is to set a via near the ground terminal pad of the electronic component so that the electronic component can be connected to the ground of the circuit board with the shortest length.
 
    (4) Design the signal line to be short. Do not increase the wiring length arbitrarily and try to shorten the wiring length as much as possible.
 
    (5) Reduce the number of connections between circuits. It is especially important to separate the circuits between the filter and amplifier input and output, which is equivalent to the cross talk countermeasure for audio circuits.
 
    (6) MCU circuit layout considerations: The oscillator circuit should only be as close to the IC oscillator pin as possible; the oscillator circuit should be kept at a sufficient distance from VDD & VSS; when the oscillation frequency is greater than 1MHz, there is no need to add osc1 & osc2 capacitors; the power supply and ground should be as short as possible and the lines should be as equal in width and distance as possible, and ceramic capacitors such as 104/103/102 should be added at the node position.
 
19. What are the precautions when developing a system for the Intel series 96 microcontroller 80c196KB?
 
A: The software of a real-time system consists of a real-time operating system plus an application program. The interface between the application program and the operating system is implemented through system calls. For an MCU using the 80C196KB operating system, only the internal RAM can be used as the TCB and all system memory (including various control tables) as well as the work and data unit of each task. Therefore, it is important to pay attention to the following points:
 
    (1) Each task is allocated its own stacking area, which serves as both the working unit of the task and the protection unit of the task control block.
 
    (2) The system's task control block only stores the stack pointers of each task, while the task status is stored in the task stack. When a task exits execution, its status is pushed into the stack through an interrupt, and then its stack pointer is saved in the system's TCB; then the stack pointer SP image value of the highest priority ready task is taken out and sent to SP; finally, the interrupt return instruction is executed to execute the new task.
 
    (3) The data and work units of each task are implemented as much as possible using stacks, which allows each task to use the same subroutine. Using stacks to implement parameter passing and as work units instead of using absolute address RAM can realize reentrant subroutines. This subroutine can be called by each task and can also be called recursively.
 
20. When sampling voltage on the demo board, it is unstable and the sampling results fluctuate. How to eliminate it?
 
   A: Generally speaking, simulators work in a voltage-regulated environment (usually 5V). If you use the simulator's A/D, you should pay attention to whether the A/D reference voltage is provided by the simulator itself or needs to be provided externally. A/D conversion requires a continuous clock cycle, so you cannot use the single-step debugging method during simulation, otherwise the A/D sampling value will be inaccurate. As for the instability of A/D sampling, you can add a capacitor to the A/D input port to play a filtering role; use the median filtering method during software processing.
 
21. How to design an electronic anti-vibration system in a car DVD system?
 
   Answer: For the car DVD system, it is best to choose a high-end DVD player, because high-end DVD players all use electronic anti-vibration system (ADVANCEDESP). When the reading in the memory buffer is reduced, the advanced electronic anti-vibration design will use a dual-speed reading system to make the reading rate twice as fast as the normal speed to reduce noise. Even if there is continuous vibration, it can still avoid the jump line. Now let's talk about what electronic anti-vibration is. Simply put: electronic anti-vibration is a signal storage-release process. First, the CD must read the signal in advance, that is, we see the acceleration of the machine, and then store the signal in RAM. What we hear when we turn on the anti-vibration is the sound passing through the RAM. This is its process. When there is no anti-vibration, it is because the signal is read 1:1, so when it is impacted, there will be skipping. When the anti-vibration is turned on, after the machine is impacted, the sound released by the RAM makes the music play continuously, and at the same time, the optical head quickly resets and searches, and when the signal is retrieved, it is immediately supplemented, so there will be no skipping. This is roughly the situation. However, this still does not meet the requirements of users, because the time brought by this method is very short, usually only 3 seconds, so the chance of sound skipping is still quite high. Increasing the RAM will also increase the cost because RAM is expensive, especially good quality ones.
 
22. In electronic anti-vibration technology, what ICs or devices are available?
 
   A: In electronic anti-vibration technology, one of the most important technologies is RAM technology. However, due to its cost, the anti-vibration time has not been increased. In other words, RAM itself has a limit. The larger the RAM capacity, the higher the cost. Many manufacturers have developed research on how to maximize the memory time within the RAM limit.
 
23. How can programming reduce program bugs?
 
A: Here are some suggestions, because the actual operating parameters in the system are within a range. The out-of-range management parameters to be considered in system operation are:
 
l Physical parameters. These parameters are mainly the input parameters of the system, including the excitation parameters, the operating parameters in the acquisition process, and the result parameters after the process. These boundaries should be set reasonably, and any parameters beyond the boundaries should be treated as abnormal excitation or abnormal response and error handling should be performed.
 
l Resource parameters. These parameters are mainly the resources of the circuits, devices, and functional units in the system, such as memory capacity, storage unit length, and stack depth. In program design, resource parameters are not allowed to be used beyond the scope.
 
l Application parameters. These application parameters are often expressed as the application conditions of some single-chip microcomputers and functional units, such as the number of erase and write times and data storage time of E2PROM and other application parameter limits.
 
l Process parameters. Refers to the parameters that change in an orderly manner during the operation of the system.
 
    For a programmer, it is necessary to develop a good habit to replace the above parameter groups with the corresponding lists of text parameters that he likes in order at the beginning of the program, and then use the text parameters that he defines to write the program. In this way, when modifying and maintaining the program, you only need to make changes at the beginning of the program, and there is no need to modify the program segments. This is easier and will not cause errors.
 
24. Some people believe that MCU will be replaced by embedded systems with ARM and other series structures. How long will the life span of MCU be?
 
   Answer: Because of the difference in functional structure and unit price between 8-bit microcontrollers and embedded system ARM, there is a big difference in the application level. ARM is suitable for advanced products with relatively complex systems, such as PDAs, mobile phones, etc. 8-bit microcontrollers are suitable for general industrial control, consumer home appliances, etc. due to their simple architecture and relatively few hardware resources. To evaluate whether microcontrollers will be replaced by ARM in the near future, we need to observe two factors:
 
Chip cost
 
    Because ARM has a high operating frequency and a large circuit, the required chip manufacturing process requires more than 0.25U, which is more expensive. The operating frequency of 8-bit microcontrollers is relatively low, the circuit is smaller, and the required chip manufacturing process is only 0.5U, which is less expensive.
 
l Functional positioning
 
    ARM has stronger functions than MCU, but they are positioned differently. Just like no one would use ARM to make a simple industrial timer switch at this stage. Of course, it would be fine if the unit price of the two was the same, but the reality is that there is a big price difference.
 
    As for the future, because the chip manufacturing cost will continue to decline, the above cost difference will have less and less impact! But I estimate that in the next 5 years, the MCU will still have a price advantage and will still survive! But will ARM streamline its architecture, reduce costs, and grab the low-end market? I think it is unlikely, ARM should develop upward. Similarly, the MCU can only develop upward, such as 16-bit, high-function... etc. The reason is that the chip manufacturing process is advancing too fast. Pressure chip design to develop towards high integration.
 
 
 
25. When programming in C for a microcontroller, how can the generated code be made as efficient as assembly language?
 
Answer: If you are programming in C language, it is unlikely that the generated code will have the same efficiency as assembly language 1:1.
 
    In order for C language commands to be recognized and executed by hardware, they must be compiled by a compiler. Compilers are divided into front-end, middle-end, and back-end. The front-end deals with programs written in various computer languages, and the back-end is connected to the basic instruction set of the processor. Therefore, if you want to achieve the highest efficiency when using C programming, it is best to understand the C compiler you are using. First test the number of assembly language statements corresponding to each C language compilation, so that you can clearly know the efficiency. When programming in the future, use the statements with the highest compilation efficiency, so that you can ensure that the same function and different C programs have the highest compilation efficiency when programming the microcontroller C. However, there are certain differences between different C compilers. The code length and execution time of an excellent embedded system C compiler are only 5-20% longer than the same function written in assembly language, so the compilation efficiency of C compilers from different manufacturers will also be different. 
 
26. Which type of microcontroller core is the ARM microcontroller similar to?
 
   Answer: Strictly speaking, ARM is not a single-chip microcomputer, but an embedded real-time operating system. ARM (Advanced RISC Machines) is a well-known company in the microprocessor industry. It has designed a large number of high-performance, low-cost, low-energy RISC processors, related technologies and software. ARM licenses its technology to many well-known semiconductor, software and OEM manufacturers in the world, and each manufacturer gets a unique set of ARM-related technologies and services. Therefore, large companies such as Intel, IBM, LG Semiconductor, NEC, SONY, Philips and National Semiconductor have ARM series in the market. Now there is no question of which ARM single-chip microcomputer is closer to which core single-chip microcomputer. Moreover, after purchasing the core, the manufacturer will add different plug-in function modules according to the different application directions of their own chips, so the functions provided by the chips with the same core are different.
 
27. Will it be difficult to switch from 51 to ARM?
 
    Answer: When switching from 51 to ARM, the principles of programming are actually the same, but you should note that ARM is a RISC architecture. There are many open source programs for ARM applications. If you want to improve yourself, you should read more programs from others. Linux, uc/os-II, etc. are all very good source codes.
 
28. I have studied the MCS51 microcontroller textbook and am very interested in it, but I lack practical experience, I don’t have any props to practice with, and my funds are limited. What should I do?
 
   A: If you are really interested in practicing without any conditions, you can download some simulation software with software simulation function to do some programming. Some of the better 51 simulation software should have this function. HOLTEK's simulation software HT-IDE3000 also has the corresponding function. It also has LCD software simulation and peripheral circuit software simulation. If you are interested, you can also download it for free: http://www.holtek.com.cn/tech/tool/ide.htm. At the same time, you can go to some electronic markets to buy some simple devices to practice building circuits to strengthen your hardware knowledge.
 
29. If you already have an algorithm implemented in C for a certain MCU, keep the framework unchanged and use assembly to optimize the core part. Are there some general principles?
 
   A: Everyone has his own programming style and habits. If you want to use someone else's program and modify it, if his program is not well modularized, it is recommended not to do so, otherwise you may end up with twice the result with half the effort instead of twice the effort. It is of course possible to refer to other people's programs, but the first thing is to read and understand the essence of the algorithm of other people's programs, rather than patching on their basis. As for algorithm optimization, you can buy some books on data structures, which have more detailed instructions.
 
30. If you want to estimate the MIPS of an algorithm, what is a good approach?
 
   Answer: The running time of an algorithm refers to the time it takes for an algorithm to run on a computer. It is roughly equal to the product of the time required for a computer to perform simple operations (such as assignment operations, comparison operations, etc.) and the number of simple operations performed in the algorithm. The number of simple operations contained in an algorithm is usually called the time complexity of the algorithm. It is a relative measure of the running time of an algorithm, generally given in the form of an order of magnitude. There are usually two ways to measure the execution time of a program:
 
l One is the post-statistical method. Because many computers have internal timing functions, programs with different algorithms can be distinguished by one or several sets of the same statistical data. However, this method has two defects: one is that the program compiled according to the algorithm must be run first; the other is that the statistical value of the time obtained depends on environmental factors such as the computer's hardware and software, which sometimes easily conceals the advantages and disadvantages of the algorithm itself. Therefore, people often use another method of pre-analysis and estimation.
 
l One is the method of pre-analysis and estimation. The time a program takes to run on a computer depends on the following factors:
 
(1) What strategy is selected based on the algorithm?
 
(2) The scale of the problem. For example, finding prime numbers within 100 or within 1000;
 
(3) The language used to write the program. For the same algorithm, the higher the level of the implementation language, the lower the execution efficiency;
 
(4) The quality of the machine code generated by the compiler. This is related to the compiler;
 
(5) The speed at which a machine executes instructions.
 
    Obviously, the same algorithm has different efficiencies when implemented in different languages, compiled with different compilers, or run on different computers. This shows that it is inappropriate to use absolute time units to measure the efficiency of an algorithm. Leaving aside these factors related to computer hardware and software, it can be considered that the size of the "running workload" of a specific algorithm depends only on the size of the problem (usually expressed as an integer n), or in other words, it is a function of the size of the problem.
 
    An algorithm is composed of control structures (sequence, branch and loop) and primitive operations (operations of intrinsic data types), and the algorithm time depends on the combined effect of the two. In order to facilitate the comparison of different algorithms for the same problem, the usual practice is to select a primitive operation from the algorithm that is a basic operation for the problem (or algorithm type) being studied, and use the number of times the basic operation is repeated as the algorithm time measurement. 
 
    MIPS algorithms are a specialized subject, and you can refer to relevant data structure books. 
 
31. What is the idea and design process of remote control encoding and decoding?
 
   A: Generally speaking, a complete remote control code consists of four parts: header code, address code, data code and check code. The header code varies from manufacturer to manufacturer. The address code and data code are both composed of logic "1" and logic "0". The purpose of coding is to send different code values ​​according to coding rules. Our most common code types are SONY, Panasonic, NEC and other manufacturer models. Remote control coding chips are most commonly used in remote controllers such as air conditioners, DVDs, and garage doors.
 
Designing a coding procedure can be divided into three parts.
 
    The first part is to understand the characteristics of the code type. The header code and address code (also called client code) of the remote control code are fixed, and the data code and check code change according to different key values.
 
    The second part is to calculate the code sending time. Most remote control codes are composed of logic "1" and logic "0", that is, a series of square waves with fixed duty cycle and fixed period. Usually the period of these square waves is milliseconds or even microseconds, and the time calculation needs to be more accurate. Therefore, when choosing the model of the code sending microcontroller, it is necessary to consider whether the running speed of the microcontroller is fast enough and whether the program running time is sufficient.
 
    The third part is the writing of the program. After selecting the microcontroller model, start designing the program flow. Generally speaking, we can use the I/O port as the output port for sending codes. The code sending program is generally composed of several subroutines, the header code subroutine, the logic 1 subroutine, the logic 0 subroutine, and the check code algorithm subroutine. Once we get the command to send the code, we first call the header code subroutine, then call the logic 1 subroutine or the logic 0 subroutine according to the client code and key value, and finally call the check code algorithm subroutine to output the check code.
 
    HOLTEK's HT48CA0/HT48RA0, HT48CA3/HT48RA3 and HT48CA6 are single-chip microcomputers designed for remote controllers. They have a dedicated infrared output port and can meet most code transmission requirements.
 
[page]
 
Designing a decoding program can also be divided into three parts.
 
   The first part is to understand the characteristics of the encoding waveform. Start by analyzing the high and low pulse widths of the encoding, and understand the waveform duty cycle and period of logic "1" and logic "0". Understand the characteristics of the header code.
 
   The second part determines the receiving method. Generally, we can use the I/O port query method or the INT port interrupt response method to receive the code. The difference between the two is that the I/O port query method consumes more of the microcontroller's running time resources, and it is necessary to continuously detect the level changes of I/O to avoid missing the valid code value; while the INT port interrupt reception method is more resource-saving. When there is an external level change, the microcontroller needs to process it and does not need to detect it all the time. However, the INT port interrupt reception method cannot distinguish the waveform characteristics of different duty cycles in the same period. When the logic "1" and logic "0" carried by the code have this characteristic, it cannot be distinguished by the INT port interrupt reception method, because the INT interrupt is only triggered at the rising edge or falling edge.
 
   The third part stores the received code value and analyzes and executes it. By judging the width of the high and low levels (timer or delay), the code value can be obtained, which is what we call decoding. Generally, when we receive three identical complete code values ​​in succession, we confirm that the code has been sent and received successfully. When the decoding is completed, we can determine which button is pressed based on the code value, and execute the corresponding button function.
 
   HOLTEK's HT48 and HT49 (with LCD) series microcontrollers can meet most decoding tasks.
 
32. In the process of learning about microcontrollers, how do you understand concepts such as pre-scaling, 12-clock mode (6-clock model), etc.?
 
   Answer: The English word for prescaler is prescaler. It divides the input frequency signal and then outputs it. HOLTEK has a most basic 8-bit I/O microcontroller HT48R05A-1. We will take this microcontroller as an example. The HT48R05A-1 has an 8-bit up-counting timer Counter. The system clock Fsys (4MHz) enters the 8-stage prescaler for frequency division, and then enters the timer counter Counter for counting. According to the software settings, the prescaler can divide Fsys by 2 to the power of n (n=1~8). For example, if the software is set to divide the prescaler by 2, then the frequency output by the prescaler is Fsys/2=2MHz, and this 2MHz signal then enters the timer counter Counter.
 
If you need detailed information about the HT48R05A-1 or other types of HOLTEK microcontrollers, you can download it from the following address: http://www.holtek.com.cn/referanc/htk_book.htm.
 
The 12-clock mode (6-clock model) should be in the MCS51 series, where 12 system clocks are one machine cycle, and 2 system clocks are one state, that is, one machine cycle has 6 states.
 
33. What are the advantages of A/D and D/A sampling rates compared to other microcontrollers?
 
     Answer: HOLTEK A/D Tyep MCU has a built-in bit-by-bit approximation A/D conversion circuit with an accuracy of 8bit/9bit/10bit and a fastest A/D conversion time of 76us.
 
    As for D/A, it generally refers to PWM output. HOLTEK A/D Type MCUs all have 8-bit PWM output, but the characteristic of HOLTEK PWM is that its output frequency is determined by the system frequency (that is, once the system frequency is selected, the PWM frequency is also determined), and its duty cycle is controlled by assigning values ​​to the [PWM] register, without occupying timer/counter resources.
 
 
 
34. When using AT89S51, the data in RAM is modified when the reset button is pressed. What is going on? Note: The data is placed outside the special register. 
 
    Answer: If it is the reset button of the RESET pin: Generally, when the MCU is reset by RESET, its special registers will be reinitialized, while the values ​​of the general registers remain unchanged.
 
     If the reset button is a power reset: it is a power-on reset of the MCU, its special registers will be initialized, and the values ​​of the general registers are random numbers.
 
35. P2.7 is used to drive an NPN transistor, with a 1K resistor in series. The problem is: when I try to write '1' to P2.7, I find that the pin can only output a level of about 0.5V. Is this circuit used properly? How to use the IO function correctly?
 
    A: Is this a problem encountered during simulation or after burning the chip?
 
    You can disconnect the external circuit of P2.7 and measure whether the output voltage is normal. If the output voltage is normal after disconnection, it means that the driving ability of P2.7 is insufficient and cannot drive the NPN transistor. PNP transistor should be used instead (generally in MCU applications, PNP driving is adopted). If the output voltage is still abnormal after disconnection, it is possible that the emulator (or chip) is damaged. 
 
36. When doing charge management, increasing the PWM frequency often comes at the expense of accuracy. If the frequencies of AT90S4433 (avr) and 78P458 (elan) used are 16kHz (8bit) and 32kHz (8bit) respectively, and you want to achieve 100kHz (above 8bit), such as atiny15. What should I do?
 
    A: The PWM you are talking about controls its frequency and duty cycle through a timer/counter, so if you want to increase the frequency, the accuracy will inevitably decrease. If you want to increase the PWM frequency, you can only do so by increasing the system oscillation frequency.
 
37. Are MCUs used in automotive electronics mostly 8-bit or 32-bit? What do you think of the prospects of MCUs in the automotive electronics market?
 
Answer: Today, automobile manufacturing is also a rapidly advancing industry, especially the application of electronics in automobiles, which enables a variety of new functions.
 
Generally speaking, automotive electronics applications are divided into three parts.
 
l Automobile engine control: speed limit control, turbocharging, fuel injection control, etc.
 
l Car comfort devices: remote control anti-theft system, automatic air conditioning system, audio and video playback system, satellite navigation system, etc.
 
l Vehicle control and braking: Anti-lock Braking System (ABS), Traction Control System (TCS), Anti-skid System (ASR), Electronic Stability Program (ESP), etc.
 
    There are many systems in the car, and they are changing with each passing day. Therefore, the type of microcontroller used depends on the specifications of each system, and the requirements are different. However, one thing is certain: the microcontroller must meet industrial specifications to withstand the harsh environment, high temperature, power supply interference, and reliability requirements of automotive applications. The functional configurations of different grades of cars are relatively different. Therefore, there should be room for 8-bit microcontrollers in lower-level systems such as mechanical control and remote anti-theft, but high-level systems such as audio and video, navigation, and future unmanned driving are not something that ordinary microcontrollers can achieve.
 
    As the automobile industry is currently controlled by several large groups in Europe, the United States and Japan, the relevant automobile electronic parts groups will choose to cooperate with large microcontroller manufacturers. Therefore, the built-in electronic systems of automobiles are also controlled by large microcontroller manufacturers. Only external systems such as remote control anti-theft and audio and video navigation are left in the market for small manufacturers to develop.
 
38. When using Samsung's s3c72n4, I feel that its time/counter is not enough. Now I need to use 3 counters at the same time, what should I do?
 
    A: Do you need three external counters or three timers? If it is three timer flags, you can take the most basic time base of these three timings as the basic count of the timer, and then use this time base to calculate the flags of the three required counting flags. In the program, you only need to check whether the flag has arrived and then take action.
 
    If you want to count 3 external pulses, this is somewhat difficult. If the external pulses are not very frequent, you can consider using external interrupts. However, this method must ensure that the frequency of the external pulses is an order of magnitude different from the MCU execution speed. Otherwise, the MCU may not be able to handle other programs and will always be processing external interrupts.
 
39. With the continuous advancement of chip integration technology, the integration technology of single-chip microcomputers is also developing rapidly. Based on the traditional 40-pin microcontroller series, Philips has launched a 20-pin microcontroller series, which allows many pins to be reused. Will the use of this multiplexing technology affect the execution of its functions in actual applications?
 
   A: Many brands of microcontrollers now have pin multiplexing functions, not just Philips. It should be said that this method has been available for several years. In actual applications, it will not affect the execution of its functions, but it should be noted that if some MCUs use multiplexing pins, the pins will have some application restrictions, which will be described in the corresponding datasheet, so you must pay attention to it when planning the system.
 
40. What is the concept of Delta-Sigma software measurement method?
 
   A: Delta-Sigma principle is generally used in ADC applications. Specifically, the working principle of Delta-Sigma ADC is that the modulator is composed of a differential, an integrator and a comparator, which together form a feedback loop. The modulator runs at a rate much higher than the bandwidth of the analog input signal to provide oversampling. The analog input is differentially (delta) compared with the feedback signal (error signal). The differential output generated by this comparison is fed into the integrator (sigma). The output of the integrator is then fed into the comparator. The output of the comparator simultaneously transmits the feedback signal (error signal) to the differentiator, and itself is fed into the digital filter. The purpose of this feedback loop is to make the feedback signal (error signal) tend to zero. The result of the comparator output is a 1/0 stream. If the density of 1 is high, it means that the analog input voltage is high; conversely, if the density of 0 is high, it means that the analog input voltage is low. The 1/0 stream is then fed into the digital filter, which converts the 1/0 stream from a high-speed, low-precision bit stream into a low-speed, high-precision digital output through oversampling and sampling.
 
    In short, Delta means differential and Sigma means integration. My understanding of Delta-Sigma software testing is to simulate the process of differential integration through software. Specifically, it detects the change of the voltage (or current) signal of the external input, and then obtains the basic situation of the external signal changing over time through software integration operation.
 
 
 
41. What methods are usually used to test the reliability of microcontroller systems?
 
    Answer: The microcontroller system can be divided into two aspects: software and hardware. If we want to ensure the reliability of the microcontroller system, we must start from these two aspects.
 
    First of all, when designing a microcontroller system, you should fully consider all possible external interferences and try to use all the means provided by the microcontroller to cut off or solve the impact of adverse external interference. Let's take HOLTEK's most basic I/O microcontroller HT48R05A-1 as an example. It provides a watchdog timer WDT to prevent the microcontroller's internal program from running wildly and making mistakes; it provides a low voltage reset system LVR. When the voltage is lower than a certain allowable value, the microcontroller will automatically RESET to prevent the chip from being locked; HOLTEK also provides the best peripheral circuit connection solution to minimize the impact of external interference on the chip.
 
When a MCU system is designed, there will be different test items and methods for different MCU system products, but there are some that must be tested: 
 
l Test the completeness of the MCU software functions. This is a test of all MCU system functions to test whether the software is written correctly and completely.
 
l Power-on and power-off test. During use, users will inevitably encounter power-on and power-off situations. The power supply can be turned on and off multiple times to test the reliability of the microcontroller system.
 
l Aging test. Test the reliability of the MCU system under long-term operation. If necessary, it can be tested in a high temperature, high voltage and strong electromagnetic interference environment.
 
l ESD and EFT tests. Various interference simulators can be used to test the reliability of the MCU system. For example, an electrostatic simulator is used to test the anti-static ESD capability of the MCU system; a surge noise simulator is used to perform fast pulse anti-interference EFT tests, etc.
 
    Of course, if there are no such conditions, you can simulate the damage that may occur during human use. For example, deliberately rub the contact port of the MCU system with the human body or clothing fabric to test the anti-static ability. Use a high-power electric drill to work close to the MCU system to test the anti-electromagnetic interference ability, etc.
 
42. When developing a microcontroller system, what are the specific standards for measuring the stability of the system?
 
   A: From an industrial perspective, there are many standards for measuring system stability, and they vary for different products. Below we briefly introduce the most commonly used standards for microcontroller systems.
 
l Electrical test (ESD)
 
Reference standard: IEC 61000-4-2
 
The purpose of this test is to test the extent to which the specimen can withstand the electrostatic discharge effects directly from the operator and the relative object.
 
l Space Radiation Tolerance Test (RS)
 
Reference standard: IEC 61000-4-3
 
This test is to verify the tolerance of the test piece to the noise scattered by the RF generator through space.
 
Test frequency: 80 MHz~1000 MHz
 
l Fast pulse immunity test (EFT/B)
 
Reference standard: IEC 61000-4-4
 
The purpose of this test is to verify the tolerance of the power line and signal line (control line) of the test piece when subjected to repeated fast transient bursts.
 
l Surge test
 
Reference standard: IEC 61000-4-5
 
This test is to determine the tolerance of the specimen to the surges caused by switching or lightning strikes when the specimen is in operation.
 
l Conducted Immunity(CS)
 
Reference standard: IEC 61000-4-6
 
This test is to verify the tolerance of the test piece to the noise transmitted by the RF generator through the power line.
 
Test frequency range: 150 kHz~80 MHz
 
Impulse
 
A test of the immunity to interference by injecting pulses into the power line or control line through coupling.
 
43. When designing software, most microcontrollers are equipped with a watchdog. It is necessary to feed the watchdog at the appropriate location in the software to prevent the software from resetting and entering an infinite loop. How to feed the watchdog appropriately, that is, how to accurately determine the running time of the software?
 
    Answer: Most microcontrollers have a watchdog timer (WDT) function to prevent program errors. HOLTEK has a basic I/O type microcontroller - HT48R05A-1, let's take it as an example to explain.
 
    First, let's understand the basic structure of WDT. It is actually a timer. The so-called feeding the dog means clearing this timer. There are two ways to feed the dog: software and hardware. Software feeding the dog means using instructions to clear the WDT, namely CLR WDT; hardware feeding the dog means hardware reset RESET. When the timer overflows, it will cause the WDT to reset, which is what we often call the watchdog. When the program is executed normally, we do not want the WDT to reset, so we need to use software instructions to feed the dog before the watchdog overflows, that is, to calculate how long it takes for the WDT to overflow. The calculation formula for the WDT overflow time of the HT48R05A-1 is: 256*Div*Tclock. Among them, Div refers to the wdt pre-division number 1~128, and Tclock refers to the clock source period. If the internal RC oscillator is used as the clock source of the WDT (the RC clock period is 65us/5V), the maximum WDT overflow time is 2.1 seconds.
 
    After we get the WDT overflow time Twdt, we usually choose to feed the watchdog at around Twdt/2 to ensure that the watchdog does not overflow and the number of times the watchdog is fed is not too many.
 
The software running time is determined by different running routes. If the software running route can be predicted, the software running time can be calculated according to T=n*T1. n refers to the number of machine cycles running, and T1 refers to the machine cycle. HOLTEK microcontrollers are RISC structures, and most instructions consist of one machine cycle. You only need to know how many instructions the software runs to calculate the running time. There is a tool for calculating the running time in HOLTEK's compilation software HT-IDE3000. However, for CISC-structured microcontrollers, an instruction can consist of several machine cycles, so it is necessary to calculate based on the specific instructions executed.
 
44. We are a professional factory that develops CNC systems. We have developed many products using various single-chip microcomputers and CPUs. We have also adopted many common anti-interference technologies in software development, such as software traps, instruction margin, watchdog and digital filtering, etc. However, they are still very unreliable in actual use, such as frequent inexplicable crashes, program jumps, I/O data errors, etc., and the repeatability of the faults is very uncertain, and they are not repeated periodically. Often, users encounter faults during use, but they cannot be reproduced, which is a headache. Repeated hardware checks have not found the cause, so the reliability of the software is very doubtful. What should I do?
 
    A: The most effective way to prevent interference is to remove the interference source and cut off the interference path, but it is often difficult to do so, so we can only see whether the anti-interference ability of the MCU is strong enough. The most common phenomenon of MCU interference is reset; as for the program running away, you can actually use software traps and watchdogs to pull the program back to the reset state; so the most important thing for MCU software anti-interference is to handle the reset state well.
 
     Generally, microcontrollers have some flag registers that can be used to determine the reset reason. In addition, you can also bury some flags in RAM. Every time the program is reset, you can determine the different reset reasons by judging these flags. You can also jump directly to the corresponding program according to different flags. This can make the program run continuously, and the user will not notice that the program has been reset when using it. 
 
    You can set some registers to accumulate in the timer interrupt, and then add to the preset value (a relatively long time), SET flags, and these actions are all in the interrupt program. The main program only needs to query the flags, but remember to clear the flags after use, and also remember to clear the time base accumulator in the interrupt after use. 
 
45. Which aspects should we focus on in the application of microcontrollers?
 
A: The learning process can basically be divided into four stages:
 
    The first stage is to browse the hardware part in the textbook to get a general understanding of the hardware structure of the microcontroller, such as ROM, RAM, address, I/O port, etc., and look at some manufacturers' data sheets, such as the HOLTEK website, which provides simplified Chinese versions of various MCU information, to strengthen the impression of the various resources provided by the IC.
 
    The second stage is to understand the binary numbers, hexadecimal numbers and software. Although there are many high-level languages ​​that can be used for microcontroller programming, I think it is better to learn assembly language (i.e., assembly language) for beginners, which is more conducive to combining with hardware and mastering the hardware structure. After knowing the concepts of assembly language, machine language, instructions, programs, source programs, and target programs, start with the MOV instruction to learn assembly language and programming. For example, the HOLTEK MCU assembly language system has 63 instructions, which are simple and easy to understand how they are connected to the hardware, and are more helpful for general learning of microcontroller instruction integration and application. Therefore, the method is to first understand a few basic MOV instructions and its machine language, and roughly establish the hardware and software concepts of the microcontroller to know that the hardware of the microcontroller is controlled and directed by instructions.
 
    The third stage is to familiarize yourself with the programmer according to the programmer's manual. Nowadays, programmers are generally connected to computers, and anyone with basic computer knowledge can quickly master the operation steps. If beginners want to quickly familiarize themselves with the microcontroller development system, HOLTEK provides detailed operation information for the microcontroller development system. You can download the HT-IDE3000 manual from the HOLTEK website (www.holtek.com.cn). 
 
    The fourth stage is to learn and master the combination language instruction system and simple programming of the single-chip microcomputer by relying on the experimental board. At the same time, it is combined with the hardware knowledge learned before, which plays the dual role of learning the software and consolidating the hardware. At the beginning, you can use simple programs written by others to verify and analyze on the experimental board, mainly to familiarize yourself with the learning method. In terms of application, it mainly focuses on the use of various I/O interfaces of the single-chip microcomputer, such as the application of A/D, D/A, PWM output ports, LCD and VFD control, and how to standardize the communication protocols of various serial output ports, etc. The driving capabilities of the various components it controls must be analyzed first, such as current and voltage issues.
 
46. ​​What are the differences in the application and development of microcontrollers in the world today?
 
    Answer: Application and development are two sides of the same coin. It is market-oriented. When there is market demand, planning and analysis at the application level will guide the development of the microcontroller in this direction.
 
47. In what areas do microcontrollers have good prospects in China?
 
   Answer: Observing the sales region proportion of each manufacturer in the past few years, it can be found that the proportion of the Chinese mainland market has gradually increased, while the Taiwan and North American markets have gradually declined. The main reason is that many product manufacturing bases have been transferred to the mainland, and the demand for MCU in the mainland has also increased. MCU products sold to the mainland are mostly used in products such as telephones, caller IDs, toys and LCDs. It is expected that the proportion of sales to the mainland will continue to increase in the future. The application areas of products in China can be divided into five major projects, including computer peripherals (high-speed modems, DSCs, power management in NBs, etc.), communications industry, consumer products (home appliances, air conditioners, etc.), automotive markets (speed controllers, controllers, anti-theft devices) and industrial applications. Some manufacturers will specifically target the consumer product market. For example, the Audio method will move towards multimedia and MP3 solutions. In addition, a series of products will be launched in PC connection applications, including wireless, network and standard application products. In addition, in the power system application, it is used in UPS (uninterruptible power supply system), Server Power (server power supply), Charger (charger) and other applications; and in the peripheral application field, it is used in Game Device, memory card, card reader, Pen Drive (flash drive) and other applications. Logic IC includes microprocessor (MPU), microcontroller (MCU), special application IC (ASIC), programmable logic device (PLD) and general standard application IC (ASSP). Different logic ICs have their own development direction, and MCU products are developing towards integrated products, hoping to add more functions to a single IC to reduce the difficulty and cost of users in system design.
 
48. Although 16-bit is also a lot, the real low-end users still use 4 and 8 bits. Those with high performance requirements can now choose 32-bit microcontrollers. And 16-bit can only play a transitional role. Is this correct? 
 
    A: Basically, we can say that microcontrollers have gone through the development process of 4-bit, 8-bit, 16-bit and 32-bit. There are many manufacturers involved and they are ubiquitously used in various areas of life. As long as it is related to the operating interface, you can find traces of MCU. The number of MCUs used has even become one of the indicators for assessing income and economic conditions abroad. Due to the steady sales of automobiles, home appliances and consumer electronics products, the MCU market will be full of vitality in 2003. In the 32-bit MCU market, the fastest growing area is still due to the large demand for automobiles, mobile phones with Internet access, PDAs, printers, digital cameras, high-speed MODEMs and other applications. Market institutions predict that it will grow by 30% in 2003 and 38% in 2004. Although the 32-bit market has great growth potential, there are only a few manufacturers that can focus on 32-bit at present. Regardless of whether it is domestic or foreign IC suppliers, the current product development strategy focus is still on the 8-bit market, and 8-bit and 32-bit MCUs have also become the targets of development for manufacturers. As for 16-bit MCU products, although the speed is faster than 8-bit, due to the awkward position of 16-bit between 8 and 32, and the price of 32-bit is also close to that of 16-bit, the industry has paid much less attention to 16-bit products.
 
49. When transitioning from the original 51 system to the ARM system, what should we pay attention to and how should we get started?
 
   A: It is difficult to convert a 51 system to an ARM system. ARM provides a series of cores, system extensions, microprocessors and system chip solutions, and has developed several cores. The main ones are as follows:
 
l ARM7: small, fast, low-power, integrated RISC core
 
ARM7TDMI (Thumb): It combines the ARM7 instruction set with the Thumb extension to reduce memory capacity and system cost. It also uses embedded ICE debugging technology to simplify system design. It also has DSP enhancement extensions to improve performance.
 
l ARM9TDMI: uses a 5-stage pipelined ARM9 core, and is equipped with Thumb extensions, debugging and Harvard bus.
 
     If you just want to learn, it is recommended to make a minimum system board first, and write a small code that can be started according to the hardware, including initializing ports, shielding interrupts, copying the program to SRAM, completing code remapping, configuring interrupt handles, and connecting to the C language entry. In fact, more practice, more experience, more electronic websites, and learning from others' development experience will help your growth.
 
50. Are Holtek's programming statements the same as C51 or related? Can you provide information or website addresses related to automotive electronic design?
 
Answer: HOLTEK programming statements are different from MCS51 in terms of assembly instructions, but many instructions are similar; and C language, each company's C compiler will be a little different, but many are similar to TURBO C, so there is still a lot of similarity, so the readability is much better than assembly language, but there are still some differences between different manufacturers. For an introduction to HOLTEK C language, please download http://www.holtek.com.cn/referanc/ht-ide3k.pdf, which is introduced in detail in Chapter 10. As for information or website addresses about automotive electronic design, you can search on GOOGLE, there should be more links. 
 
51. How to understand the following concepts:
 
MTP = Multi-Time Programming (via parallel programmer)
 
ISP = In-System Programming (via serial interface)
 
IAP = In-Application Programming?
 
Answer: MTP means that the program of the microcontroller can be repeatedly burned. Its program memory (Program ROM) can be divided into the following types:
 
l Window with EPROM: It provides space for users to change programs. It has a window-type ceramic package and uses ultraviolet light to clear data. It can be burned repeatedly, but the packaging cost is very high. It is only suitable for small-scale production or experimental use.
 
l EEPROM: A rewritable/erasable component. This type of memory allows the program content to be cleared or modified without the need for window packaging, which can save packaging costs and is also convenient for reuse, but the production process is more complicated.
 
l Flash EPROM: When a large amount of non-volatile program memory needs to be cleared/written, Flash EPROM can provide a better solution than traditional EEPROM, because Flash EPROM performs better than EEPROM in terms of clear/write cycle times and speed. Using Flash ROM as program memory does not require the special window-type ceramic packaging of EPROM, so the price is not much different from OTP (One Time Programming), which is quite reasonable, and it also has the function of repeated burning and writing.
 
    ISP (In-System Programming) means that blank devices on the circuit board can be programmed with end-user code without removing the device from the circuit board. Programmed devices can also be erased or reprogrammed using ISP. The implementation of ISP is relatively simple, and generally requires very little external circuit assistance. The general practice is that the internal memory can be rewritten by the host computer software through the serial port. For a single-chip microcomputer, data from the host computer can be received through SPI or other serial interfaces and written into the memory. Therefore, even if we solder the chip on the circuit board, as long as we leave the serial port for the interface with the host computer, we can rewrite the internal memory of the chip without removing the chip.
 
    Advantages of ISP The advantage of ISP technology is that it does not require a programmer to experiment and develop the MCU. The MCU chip can be directly soldered to the circuit board, and the finished product is completed after debugging. This eliminates the inconvenience of frequently inserting and removing chips during debugging.
 
    IAP (In-Application Programming) means that the MCU can obtain new code in the system and reprogram itself, that is, the program can be changed by the program. The implementation of IAP is relatively complicated. When implementing the IAP function, there must be two storage areas inside the microcontroller, generally one is called the BOOT area and the other is called the storage area. The microcontroller is powered on and runs in the BOOT area. If the conditions for external rewriting of the program are met, the program in the storage area is rewritten. If the conditions for external rewriting of the program are not met, the program pointer jumps to the storage area and starts to execute the program placed in the storage area, thus realizing the IAP function. IAP technology maps the Flash memory into two storage bodies from a structural perspective. When running a user program on one storage body, the other storage body can be reprogrammed, and then the program is transferred from one storage body to another.
 
    Advantages of IAP IAP technology maps the Flash memory into two storage bodies from a structural point of view. When the user program on one storage body is running, the other storage body can be reprogrammed, and then the program can be transferred from one storage body to another. The implementation of IAP is more flexible. Usually, the serial port of the microcontroller can be connected to the RS232 port of the computer, and the internal memory can be programmed through a specially designed firmware program. Remote upgrades and maintenance can be easily achieved through the existing INTERNET or other communication methods.
 
52. There are many types of single-chip microcomputer development system products on the market. If you want to develop a 51 series single-chip microcomputer, which type of emulator and programmer (one chip at a time) is better?
 
    A: As you said, there are many types of emulators for the 51 series microcontrollers. As for which emulator to choose, I cannot give you very good suggestions because HOLTEK IC is not a 51 core and all emulators are developed by HOLTEK itself. Moreover, there are many 51 emulators on the market with prices ranging from 1500 to 10000. So if you want to choose, you can google the forums related to emulators on the Internet, see other users' comments, and choose an emulator with the best cost performance.
 
53. Does HOLTEK's C language have instructions for bit manipulation and reading defined register addresses? If so, what are they?
 
   A: HOLTEK's C language is similar to standard C. It not only has standard C bit operations, & (bitwise AND, bitwise OR), ^ (bitwise XOR), ~ (negation), << (left shift) and >> (right shift); it also has corresponding built-in functions to implement left and right shifts with and without carry for integers and long integers. The operation of the address of defined variables is also the same as standard C, which can be achieved through the pointer operators * and &.
 
54. After completing the program writing and running, the result is that all the memory from R0 to R7 are occupied, but I didn’t use any of them. Why is that?
 
A: It depends on the type of microcontroller used. The definitions of R0 to R7 are different for different types of microcontrollers. If R0~R7 are defined as special registers, then these registers will naturally be affected during operation. For example, the execution of the operation program will affect the value of the status special register. If R0~R7 are defined as general registers, then it may be that they are not initialized at the beginning of the program. When the microcontroller is powered on and reset, the value of the general register is usually random.
 
55. Please recommend some better theoretical and practical teaching materials, and their supporting compilation, simulation and burning hardware and software?
 
Answer: There are many types of single-chip microcomputers in the market today, and they are widely used. Take HOLTEK as an example. HOTLEK's single-chip microcomputer is an 8-bit single-chip microcomputer with RISC structure, which can be widely used in household appliances, security systems, handheld games, etc. Generally speaking, it can be divided into I/O type single-chip microcomputer, LCD type single-chip microcomputer, A/D type single-chip microcomputer, A/D with LCD type single-chip microcomputer, etc. We have made the Chinese information of these single-chip microcomputers public on the HOLTEK website www.Holtek.com.cn. The download address of the user manual of various HOLTEK single-chip microcomputers is: http://www.holtek.com.cn/referanc/htk_book.htm; the download address of HOLTEK single-chip microcomputer software/hardware application examples is: http://www.holtek.com.cn/tech/appnote/appnote.htm; the download address of HOLTEK single-chip microcomputer support tools is: http://www.holtek.com.cn/tech/tool/tool.htm.
 
56. What are some methods to achieve PWM at 100kHz (8bit or above)? It would be best if it supports C compilation.
 
Answer: To achieve a PWM frequency of 100kHz (8bit) or above, the MCU frequency requirement is 100kHz*256=25.6MHz. Therefore, to achieve this requirement, the MCU needs to meet two conditions: 1. The MCU has PWM output; 2. The system frequency reaches 25.6MHz, or the MCU can provide a 25.6MHz frequency (ATtiny15 has a 25.6MHz frequency as the timer/counter clock).
 
57. The chairman of ARM believes that medical electronics will become the driving force for the growth of the electronics industry in the next 10 years, and EMS predicts that medical electronics will become the largest foundry market. Bluetooth enhances the mobility of medical products and will be widely used. So with the development of medical electronics, will the application of microcontrollers in this field become larger? How many microcontrollers are most commonly used in medical electronics?
 
Answer: With the development of 16/32-bit embedded RISC, its application in the field of medical electronics will be expanded.
 
    The general electronic medical care products are as follows: pen-type electronic thermometers, baby pacifier-type electronic thermometers, temperature-measuring music bottles, women's electronic thermometers, electronic blood pressure monitors and other products. Medical electronic instruments include pH meters, colorimeters and other products that can be completed using 8-bit microcontrollers.
 
    However, in terms of research and manufacturing, for medical electronic instruments, there are already manufacturers manufacturing electrocardiographs, pH meters, electronic thermometers and other instruments. The instrument center can make its own oscilloscopes, microscopes, etc., as well as X-ray machines, ultrasound diagnostic equipment, computer tomography systems, pacemakers, monitors, auxiliary diagnostic systems, expert systems, etc. Larger-scale replication of medical embedded system electronic instruments requires the use of 16-bit and 32-bit microcontrollers.
 
58. The operating temperature range of ordinary commercial-grade microcontrollers is 0-70 degrees. What problems will occur when used in an environment below 0 degrees or above 70 degrees? In addition to the different temperature ranges, are there any other differences between commercial-grade chips and industrial chips? (such as anti-interference performance)
 
    Answer: Generally, single-chip microcomputers can be divided into three types according to the operating temperature: civil grade (commercial grade), industrial grade and military grade. The temperature range of civil grade is 0℃~70℃, industrial grade is -40℃~85℃, and HOLTEK MCU belongs to this grade. The military grade is -55℃~125℃. If it is a general commercial grade single-chip microcomputer, when the IC is used beyond the specification range, some ICs may not work or work abnormally.
 
     As for the anti-interference performance, it belongs to the EMS (electromagnetic noise tolerance) test of the entire product. It is one of the tests in EMC (electromagnetic compatibility), and the other is EMI (electromagnetic radiation interference). Each country has its own EMC certification standards. For example, under the commonly used test specifications under the European EMC directive, the regulations EN61000-4-2 are for electrostatic test (ESD). The purpose of this test is to test the degree to which the test piece can withstand the electrostatic discharge effect directly from the operator and the relative object. The regulations are as follows:
 
Air Discharge
 
Level 1 2KV
 
Level2 4KV
 
Level3 8KV
 
Level4 15KV
 
The above is just an example. For example, antistatic ability is not only related to IC performance, but also directly related to application circuit and PCB layout.
 
59. How do the various inputs communicate with the MCU?
 
   A: First, it is necessary to determine whether such input signals are compatible with the signal level of the MCU system. If they are not compatible, an external circuit or an integrated circuit block is required to complete the level conversion. The second is to choose the communication method. The basic communication methods are divided into parallel communication and serial communication. Both have their advantages and disadvantages. Parallel communication is fast, but the disadvantage is that as many transmission lines are required as the number of data bits. This is not suitable when there are many bits and the transmission distance is long; serial communication is the opposite of the former, with low transmission cost but low transmission speed. Finally, in order to ensure the success of communication, the communicating parties must have a series of agreements, namely the communication protocol, which must make clear provisions on when to start communication, when to end communication, when to exchange information, etc.
 
60. Which model of 51 single-chip microcomputer has two serial ports, 16KEPROM, and 512 bytes of RAM?
 
    Answer: PHILIPS Semiconductor's P87C591 should be able to meet this condition. Currently, semiconductor manufacturers that produce 51 microcontrollers include INTEL, ATMEL, PHILIPS, ANANOG DEVICES, DALLAS, etc. You can log on to their websites to query the corresponding product information.
 
61. What are the problems of software anti-interference in embedded development? How to solve them?
 
    A: Regarding software anti-interference issues and strategies, if these principles can be followed well in actual applications, combined with anti-interference measures of hardware circuits, the interference effects can be basically eliminated. However, sometimes due to the complexity of the program itself and the limitations of chip resources, coupled with the limitations of the programmer's own capabilities, it cannot be perfect. So we can only give some suggestions. As for the specific implementation, you need to constantly explore and accumulate experience in your usual project practice. The following are the answers to previous questions about software anti-interference, for reference only:
 
   The most effective way to prevent interference is to remove the interference source and cut off the interference path, but it is often difficult to do so, so we can only see whether the anti-interference ability of the MCU is strong enough. The most common phenomenon of MCU interference is reset; as for the program running away, in fact, the software trap and watchdog can also be used to pull the program back to the reset state; so the most important thing for MCU software anti-interference is to handle the reset state well.
 
   Generally, microcontrollers have some flag registers that can be used to determine the reset reason. In addition, you can also bury some flags in RAM. Every time the program is reset, you can determine the different reset reasons by judging these flags. You can also jump directly to the corresponding program according to different flags. This can make the program run continuously, and the user will not notice that the program has been reset when using it. 
 
62. Will voice recognition be the next consumer hotspot for microcontrollers?
 
   Answer: Voice recognition has been applied to low-end toys many years ago, such as the left and right front and back control of remote control cars. Educational toys use voice to compress and encode the words according to the length that the memory can accommodate. When the same voice is sent again in the future, it can be processed and recognized by the microcontroller, and then the corresponding action can be taken. Depending on the cost, the related MCU resources and speed, the quality of the recognition technology algorithm (operation rule) used, the size of the memory, etc., the recognition rate and word length of the designed products are also very different. This low-end market should have a bright future with the current drop in chip prices. It depends on whether the innovative application of the product is attractive! High-end voice recognition applications are on PCs (personal computers), with CPU-level resource speeds and hard disk memory capacity, but this market has nothing to do with hardware (microcontrollers)!
 
    Another application of speech recognition is embedded systems. For example, most current mobile phones are equipped with speech recognition phone books. In fact, general embedded systems such as PDA, DSC, MP3, etc. have the ability to build in this function. It depends on how much hardware resources are needed and the effect that can be achieved. The functional positioning of the product is very important. Whether speech recognition is necessary needs to be evaluated in actual usage!
 
63. How to design and implement a low-cost device for measuring battery pack voltage with a common mode range of 0-120V?
 
A: The so-called high common-mode input voltage here refers to the high-range common-mode input voltage. The following is an explanation of some concepts of op amps:
 
    The so-called dynamic range of an op amp refers to the output and input voltage range of the op amp (OP) when it is not saturated and in normal operation. Generally speaking, the larger the dynamic range, the higher the effective utilization rate of the power supply voltage. For example, when processing signals of the same level, there is no need to deliberately increase the power supply voltage to achieve energy saving effects. Especially in the case of portable consumer electronic products that require low voltage and low power consumption, high-efficiency power supply voltage has always been the focus of much attention, especially the ground potential of the op amp. If it is set at the midpoint of the positive and negative power supply voltages of Vcc~VEE (that is, the operating point), an extremely wide dynamic range can be obtained. In view of this, designers usually make the input dynamic range greater than the output dynamic range without reducing the output dynamic range.
 
    When the potential of the input signal is VEE (power supply voltage), the polarity of some OPs will be reversed. Although the output allows saturation caused by excessive input, in most cases, polarity reversal is not allowed. Therefore, when two single power supplies are used in the op amp, the output will be reversed before the input signal reaches VEE. It should be noted that even if the op amp is used with a single power supply, if it exceeds 0.5V below VEE, that is, VEE-0.5V, the output polarity may also be reversed.
 
    The so-called common-mode input voltage range VICM (common-mode input voltage) refers to the range of common-mode voltage that can be applied between the two input terminals and the ground. Although the applied common-mode voltage will not cause component damage or other problems when it exceeds this range, it will stop the function of the op amp. As long as the differential input voltage acts normally as an amplifier, it is basically 0 volts. It is ideal for the common-mode input voltage range VICM to be the same as the positive and negative power supply voltages.
 
    Generally, an op amp will use the CMR (common-mode signal elimination ratio) of a differential amplifier to remove the same component. When it is necessary to expand the in-phase range, the input Vs2 signal of the inverting amplifier A2 with a gain (Game) of 1/10 can be used, and the input Vs1 signal of the inverting amplifier A1 with a gain (Game) of 1/10 can be added in an addition manner. In this way, differential amplification with an expanded in-phase input range can be achieved. 
 
    If the common mode range is designed to be between 0 and 120V, the above-mentioned inverting amplifier A1 can use R1=100K, Rf=10K, and the inverting amplifier A2 can also use R1=100K, Rf=10K, and a 10K resistor is connected in series from the output of the inverting amplifier A1 to the negative input port of the inverting amplifier A2. 
 
64. When using a single-chip microcomputer to control the LCD, the overflow interrupt of T1 is used to display the refresh clock information. In the main program loop, in order to display floating-point numbers, the spritf() function is continuously called, but the clock information is no longer refreshed. After disabling this function, it returns to normal. Will calling this function affect the interrupt of the timer/counter?
 
Answer: This should be related to the program. Generally speaking, the sprintf() function will not affect the interruption of the timer/counter. Since I haven't seen the specific program, I guess the reason may be that the part of the program that initializes the timer conflicts with the buffer used by sprintf(), causing the timer initialization error.
 
65. What IC is LM4915?
 
Answer: LM4915 is an audio power amplifier, commonly used in low-voltage applications such as mobile phones with a single earpiece, PDAs and other portable audio devices. It provides high-quality power output to drive sound-generating devices with very few external components. 
 
66. RISC architecture microcontrollers are widely used nowadays. What are its main features? What are its advantages? Also, what are the characteristics of Harvard architecture in processors?
 
    A: In terms of MCU development, there are two main streams in terms of architecture: RISC (Reduced Instruction Set Computer) and CISC (Complex Instruction Set Computer). RISC means that all instructions of the MCU are composed of some simple instructions. Simple instructions mean that the circuit of the MCU can be optimized as much as possible, thereby increasing the execution rate and reducing the time required for an instruction to the minimum. HOLTEK's series of MCUs are designed with RISC structure.
 
    In addition, because the instruction set of RISC is concise, many tasks must be combined with simple instructions, and the tasks for more complex combinations need to be performed by a "compiler". Because CISC MCU provides more instruction sets in hardware, many tasks can be replaced by one or several instructions, so the compiler's work is reduced a lot. For a numerical calculation program, the MCU using the CISC instruction set may only need ten machine instructions to calculate an integral operation, while when the RISC MCU executes the same program, because the CPU itself does not provide floating-point multiplication instructions, it may need to execute hundreds of machine instructions (but each instruction may only take one-tenth of the time of the CISC instruction). The action of converting the programming language into machine instructions is performed by the compiler of the programming language, so the compiler of the RISC MCU will be more complicated. Because the same high-level language A=B*C operation may have many combinations when converted into machine instructions in the RISC MCU, and the "time/space" combination of each combination is different. Therefore, the choice between RISC and CISC seems to be a balance between MCU hardware architecture and software (Compiler). There should be no one side with an absolute advantage. We can only say that there are different products to meet different needs. For example, a simple printer core MCU is suitable for using a RISC MCU with stable performance but better unit instruction efficiency.
 
    As for the processing method of single-chip microcomputer, there are two types of system structures of single-chip microcomputer at present: one is to use program and data memory separately, that is, Harvard structure, and most of the current single-chip microcomputers have this structure. The other is to use the principle similar to the Von Neumann of PC, and do not make a logical distinction between program and data memory, that is, Princeton structure. 
 
67. In many cases, the measurement system with a single-chip microcomputer as the main controller needs to maintain trouble-free operation for a long time, so its self-diagnosis becomes the key. Please introduce some knowledge about the fault self-diagnosis of the single-chip microcomputer system?
 
    Answer: To ensure that the system can run for a long time without failure, it is very important to prevent interference. The most effective way is to remove the interference source and cut off the interference path, but it is often difficult to do so, so we can only see whether the anti-interference ability of the microcontroller is strong enough. The most common phenomenon of microcontroller interference is reset; as for the program running away, in fact, the software trap and watchdog can also be used to pull the program back to the reset state; so the most important thing for the microcontroller software anti-interference is to handle the reset state well. 
 
    Generally, microcontrollers have some flag registers that can be used to determine the reset reason. In addition, you can also bury some flags in RAM. Every time the program is reset, you can determine the different reset reasons by judging these flags. You can also jump directly to the corresponding program according to different flags. This can make the program run continuously, and the user will not notice that the program has been reset when using it. 
 
68. The functions of MCU can only be displayed after the program code is written into ROM. When testing MCU, the program is written into ROM and the corresponding test vector is provided to the input pin. For OTP type MCU, it can only be programmed once, so each time the packaged finished product is tested, one is scrapped. As far as I know, most of Holtek's MCUs are OTP version microcontrollers. How does Holtek solve this testing problem?
 
   A: If you are a tester of an IC manufacturer, based on HOLTEK's experience, the test is divided into two steps. 1. Burn the code into the ROM of the bare chip to test whether the IC can write the program normally. If the test passes, use ultraviolet light to erase the ROM code of the bare chip and package it. 2. Use an external test circuit to test the logic circuit of the packaged IC. 
 
    If you get the packaged chip from the manufacturer and test it yourself before selling it, all you can do is measure the logic circuit of the IC by measuring the I/O port resistance, diode value and other parameters. You cannot test whether the ROM code can be written correctly, unless you are the original designer of the IC and know how to test the Test Rom reserved for the IC (if any). 
 
69. As a tester for an IC manufacturer, do you conduct the test on the entire wafer, or on each die after cutting the wafer into dies?
 
Answer: The bare chip ROM Code is burned using a needle pressure machine, so the entire wafer must be burned together, and a single die cannot be arranged neatly for burning. 
 
70. “The bare chip ROM Code is burned using a needle pressure machine, so the entire wafer must be burned together, and a single die cannot be arranged neatly for burning.” Is the test at this stage only used to test the OTP itself, or is it to write targeted program code and apply corresponding test vectors to the input pins to test whether the entire MCU functions correctly?
 
A: When the chip is in the wafer stage and has not been cut, the DC test, Function test, etc. must be completed during the test. If it is an OTP type chip, the code burning work must also be solved. It is difficult to handle after cutting! The Probe Tester is actually divided into two parts. The Probe (needle pressure) is the mechanical part, which has the function of position alignment and chip row testing. The ports on the chip can be led out to the tester at the back. The tester is basically a specially equipped computer device. Different chips can be tested by writing different test programs.  
 
71. How to write a well-tested program code to achieve high functional test coverage?
 
Answer: The test method should be planned in the initial design and simulation stage of the chip circuit. Since there are very powerful chip design and test pattern tools nowadays, it is possible to quickly calculate whether the test pattern coverage (test coverage - the 0/1 toggle rate of the circuit logic) meets the requirements! As for testing the MCU, it should be to execute some built-in test instructions so that all circuits have been toggled. This has nothing to do with changes in instruction combinations.  
 
72. If the package affects the OTP and causes the chip to not work properly, but the MCU's logic circuit has passed the test, how to solve it?
 
A: After packaging, we test OTP in three steps. 1. Check whether the ROM inside the chip is empty. 2. Write a part of the required code to verify whether it is ok. 3. Test the logic circuit. Once the bare chip is scratched, the static current will increase. Once these three steps are tested OK, then the OTP package chip is basically qualified. [page]
 
73. Let’s take PIC16F87X as an example: When the MCU is in sleep mode, using WDT timing, how can we make the timing relatively consistent over a wide temperature range with the error as small as possible?
 
    Answer: Generally, when the MCU is in sleep mode, the WDT (watchdog) is in stop state. The main purpose of using WDT is that when the program is running, the MCU is interfered by external noise, which causes the program to run randomly or the MCU to crash. At this time, the WDT (generally, the WDT clock source is the internal RC oscillator) is needed to save itself and reset. When the MCU is in sleep mode, the MCU is in power saving mode. Since the main oscillator stops, the program does not run. At this time, the WDT can stop working (in this mode, the WDT clock source is the main crystal oscillator system). If the MCU is in sleep mode, but the WDT can continue to work, there is only one purpose at this time, which is to use the WDT time period for timing work (because the program stops running, the WDT counter cannot be cleared, so the WDT count will definitely overflow). In this mode, since the main oscillator stops (because of power saving), the WDT clock source can only be the internal RC oscillator, so the frequency of the RC oscillation will drift due to changes in operating temperature and voltage. Therefore, it is not recommended to use WDT for timing in power saving mode. 
 
    If you want to do timing work in power saving mode, there is a good suggestion. You can use the HOLTEK MCU dual oscillation series, such as HT49XX, HT47XX, HT48XX, HT46R6X and other series. The advantage is that in power saving mode, the main oscillation stops and the second oscillation system maintains oscillation. This oscillation system is the RTC (Real Time Clock 32768Hz oscillation system), and the operating current is maintained between 2~3uA (operating voltage 3V). Because it uses a 32768 crystal oscillator, it is not affected by operating temperature and voltage changes, and can accurately perform timing work. 
 
74. When developing an electronic measuring device that needs to operate reliably for a long time, how to solve the problems related to self-diagnosis of faults in the single-chip microcomputer (DSP) system (including the main controller, peripheral devices such as AD, RAM, ROM, etc.)?
 
    Answer: DSP is a chip specially used for digital signal processing. Compared with single-chip microcomputer, DSP device has higher integration, faster CPU, larger memory, strong computing power, fast operation speed, and can meet the requirements of the system. It has built-in serial transmission rate generator and FIFO buffer. It provides high-speed, synchronous serial port and standard asynchronous serial port. Some chips integrate A/D and sample/hold circuits to provide PWM output. DSP device adopts improved Harvard structure, has independent program and data space, and allows simultaneous access to program and data. Built-in high-speed hardware multiplier and enhanced multi-stage pipeline make DSP device have high-speed data operation capability. Although DSP has strong computing power, its event management capability is weak, and it directly supports few I/O ports. In order to conveniently realize human-computer interaction, DSP and single-chip microcomputer are used to work together: the single-chip microcomputer is used as the host to control the DSP through the communication interface; at the same time, the strong peripheral device management capability of the single-chip microcomputer is used to realize human-computer interface, display and other functions. The main working process is: the input and output signals of the spring are conditioned by the filter circuit, converted into digital signals by the A/D converter, and then enter the DSP for calculation. The diagnostic results are sent to the microcontroller through the communication interface circuit. The microcontroller displays the results on the LCD and sends them to other application interfaces through the serial port.  
 
    Because the DSP circuit completes data acquisition and digital filtering, the software design mainly includes DSP programming and single-chip microcomputer programming. The main tasks of the DSP program are initialization, management of DSP peripheral circuits and completion. In terms of fault self-diagnosis, the main controller part mostly uses built-in algorithms to complete fault diagnosis and other tasks. The single-chip microcomputer program includes keyboard control program, LCD drive display program, and program for communicating with DSP and other machines. For other parts of the fault self-diagnosis, please refer to the description at the beginning of this board for processing.  
 
75. There is a temperature control switch in series in the power supply circuit. Under normal circumstances, the resistance is very small. When the temperature rises, the resistance increases. At this time, the CPU working voltage is about 3.1V. It seems to be working in the reset state. The LCD keeps flashing. I want to judge in the software: if there are 5 consecutive power-on resets, and the interval between each does not exceed 100ms, all functions will be turned off. But in this case, the CPU will always work in the reset state. Will there be any problems?
 
   A: That is to say, the voltage will fluctuate around 3.1V, and the lowest working voltage of the CPU is 3.1V, so it will cause the CPU to reset all the time. If this is the case, it may cause abnormal CPU reset. Normal power-on reset means that the power supply voltage rises from 0V to VDD; power-off reset means that the power supply voltage drops from VDD to 0V and then recovers to VDD; so no matter what, the reset process must be the process of the voltage rising from 0V to VDD. If, as mentioned, the voltage drops from more than 3.1V to less than 3.1V, but does not completely drop to 0V, and then rises again, it is easy to cause the CPU to reset incompletely and fail to work normally.  
 
   The general solution is to use a low voltage reset circuit, which can be a transistor reset circuit, or a low voltage reset IC. For example, HOLTEK's HT70xx series is a very good low voltage reset IC. You can check the relevant information at the following website: http://www.holtek.com.cn/products/power_4.htm   
 
76. For example, if we want to subtract 50 from 400, how can we use SUBB in the program statement to implement it?
 
    Answer: The subtraction instruction in the instruction system of MCS-51 microcontroller only has one set of subtraction instructions with borrow (SUBB), but no subtraction instruction without borrow. If you want to perform subtraction without borrow, you need to clear the carry C with an instruction before subtraction. The specific instruction is: CLR C, and then subtract. When performing multi-byte subtraction, you should first perform low-byte subtraction without carry. The specific method is to first CLR C, then use SUBB. Subtraction of high bytes in the future needs to use subtraction with carry, and you can directly use the SUBB instruction.  
 
77. In order to save power, the microcontroller system often needs to enter the power-down state. At this time, what state should the PIN of the microcontroller's I/O port be set to in order to achieve the lowest power consumption?
 
    Answer: The I/O port of the microcontroller can be used as input and output status. Take the HT48R05A-1, the simplest I/O microcontroller of HOLTEK, as an example. When used as an input, it can be set to a Schmitt input with a pull-up resistor; when used as an output, it is a CMOS output. If the program enters the power saving state (HALT), first of all, each useful I/O still needs to output a certain value to ensure that the external circuit works normally. At the same time, please be careful not to keep the external circuit in a long power consumption state (such as turning on the relay for a long time); for the I/O port that is not used temporarily, in order to save power consumption, we recommend setting the I/O to the output state and the output is low.  
 
78. How can I quickly learn to use the 51 series and Cygnal series microcontrollers?
 
    Answer: It is recommended to buy a set of ARM development learning boards and simulators (you can find one suitable for you on the Internet), and learn the basic development methods of ARM in practice with the textbooks. First, you can familiarize yourself with the basic principles of ARM instruction set, architecture, operation mode, etc. through simple program writing. If you have a certain knowledge base of single-chip microcomputers, I believe you will be able to master it soon. Next, because most 32-bit ARM applications will use operating systems, you can choose an embedded real-time operating system suitable for your learning according to your personal computer knowledge level, practice more on the computer to master the basic methods of embedded system design, learn the programming of operating system applications, and further master the system application development based on ARM including software and hardware. This step requires high-level language programming and operating system knowledge, which may be difficult for non-computer professionals, but everything depends on human efforts. I believe that as long as you are determined, difficulties can always be overcome. In addition, there are many forums on ARM development on the Internet. You can often go there to download relevant learning materials, ask experts, and communicate with each other. I believe it will be helpful. 
 
79. For the same function, which MCU uses RISC or CISC core, which one has a larger code size, that is, which one requires larger RAM and ROM?
 
Answer: Microprocessors can be divided into two categories, RISC and CISC, depending on the complexity of the microinstructions. The following will first explain these two categories: 
 
1. Complex Instruction Set Computer (CISC)  
 
    CISC is a chip design system designed to facilitate programming and improve memory access efficiency. Early computers were programmed using assembly language, and CISC came into its own because memory was slow and expensive. Before the mid-1990s, most microprocessors used CISC systems, including Intel's 80x86 and Motorola's 68K series.  
 
1. Instruction characteristics of CISC system  
 
    Use microcode. The instruction set can be executed directly in the microcode memory (which is much faster than the main memory). Newly designed processors only need to add fewer transistors to execute the same instruction set, and new instruction set programs can also be written quickly. 
 
Large instruction set: can reduce the number of lines of code required for programming, reducing the burden on programmers. Instruction set corresponding to high-level language: includes dual operand format, register to register, register to memory, and memory to register instructions.  
 
2. Advantages and disadvantages of CISC system  
 
    Advantages: It can effectively shorten the microcode design time for new instructions, allowing designers to achieve upward compatibility with CISC-based machines. New systems can use a superset of instructions that includes earlier systems, so they can use the same software used on earlier computers. In addition, the format of microprogram instructions matches high-level languages, so compilers do not have to be rewritten.  
 
   Disadvantages: The instruction set and chip design are more complex than the previous generation of products. Different instructions require different clock cycles to complete. Slower execution of instructions will affect the execution efficiency of the entire machine.  
 
2. Reduced Instruction Set Computer (RISC)  
 
    RISC is a chip system designed to increase the speed of processor operation. Its key technology is pipeline operation (Pipelining): completing multiple instructions in one clock cycle. Superpipeline and superscalar technology have been widely used in chip design. RISC system is mostly used in non-x86 camp high-performance microprocessor CPUs, such as HOLTEK MCU series. 
 
1. Instruction characteristics of RISC system  
 
Reduced instruction set: Contains simple, basic instructions, through which complex instructions can be combined.
 
Same length instructions: Each instruction is the same length and can be completed in a single operation.
 
Single machine cycle instructions: Most instructions can be completed in one machine cycle, allowing the processor to execute a series of instructions at the same time.
 
2. Advantages and disadvantages of RISC system  
 
    Advantages: Using the same chip technology and the same operating clock, the RISC system will run 2 to 4 times faster than the CISC system. Since the instruction set of the RISC processor is streamlined, its memory management unit, floating point unit, etc. can be designed on the same chip. The RISC processor is simpler to design than the corresponding CISC processor, and the time required will become shorter. It can apply more advanced technologies than CISC processors to develop faster next-generation processors.  
 
    Disadvantages: The operation of multiple instructions requires programmers to carefully select the appropriate compiler, and the amount of code written will become very large. In addition, RISC system processors require faster memory, which is usually integrated into the processor, that is, L1 Cache (first level cache). 
 
To sum up the above, if we want to further compare the differences between CISC and RISC, we can analyze it from the following points: 
 
1. Formation of instructions
 
    CISC adopts the design of microinstruction code control unit because of the complexity of its instructions, while 90% of RISC instructions are completed directly by hardware, and only 10% of RISC instructions are completed by software in a combined manner. Therefore, the instruction execution time of RISC is shorter, but the ROM space required by RISC is relatively larger. As for the RAM usage size, it should be more related to the application of the program.  
 
2. Addressing mode
 
    CISC requires more addressing modes, while RISC has only a few addressing modes. Therefore, when the CPU calculates the effective address of the memory, CISC occupies more bus cycles.  
 
3. Execution of instructions
 
   The format of CISC instructions varies in length, and the number of cycles during execution is not uniform, while the RISC structure is just the opposite, so it is suitable for the design of pipeline processing architecture, which can achieve the goal of completing one instruction in one cycle on average. Obviously, RISC is simpler than CISC in design. At the same time, because CISC has too many execution steps, the waiting time of idle unit circuits increases, which is not conducive to parallel processing design. Therefore, in terms of performance, RISC still has the upper hand over CISC. However, RISC has the disadvantage of increasing the size of application code due to the simplification of instructions, requiring a larger program memory space, and having more types of instructions.  
 
80. How to design a camera that can take pictures, store, output, and synchronize videos. This circuit can be connected to a monitor for monitoring purposes. When not taking pictures, the image is real-time. When taking pictures, the image on the monitor will stop there and display the pictures taken. The pictures taken can be stored and can be called up when needed. How can this be done?   
 
A: Some technical explanations for digital cameras: 
 
    Digital cameras use JPEG or MPEG-4 image compression standards, and the dedicated control chipset responsible for the center is gradually moving towards single-chip, and the single chip generally contains data compression and memory control. From the perspective of the control method of the entire system, the parameters that affect the quality of digital cameras include: lens, exposure device, viewfinder, forward-looking screen, image storage, Gamma correction, color balance and correction, storage device and editing software, etc., which are mainly divided into two major control parts: one is responsible for I/O interface, JPEG image processing, data compression and storage, and the other is responsible for handling all automatic optical processing functions such as Auto Iris (AI), Auto Focus (AF), Auto Exposure (AE) and White Balance (White Balance) control. In the past, the control of these two major parts was handled by two microcontrollers (MCU) respectively, and has now been gradually replaced by a single MPU or DSP plus a microcontroller. 
 
   The brightness, color and distribution of the light reflected by the captured object are processed by the photoelectric conversion element CCD (or CMOS Sensor) and converted into digital signals, and then the captured image is stored in the memory of the digital camera. The signal transmission method is analog R. G. B. signal converted from CCD to digital R. G. B., and the whole process is achieved through signal amplification, Gamma correction and white balance correction; the digital R. G. B. data is then converted into brightness data (Y) and two color differences (Cr, Cb). When the image data is compressed, if the compression ratio is 1/4, the memory capacity occupied by the image data will be reduced to 1/4. For example, the image data with a memory capacity of 6Mbit is reduced to 1.5Mbit, and the digital data memory capacity of a frame will be reduced to 3Mbit after re-sampling and rearrangement of Y. Cr. Cb data, of which Y occupies 1.5Mbit, Cr and Cb together occupy 1.5Mbit. The whole conversion process will not affect the vertical and horizontal resolutions, which is called line re-sampling and recovery.  
 
   Let's talk about CCD (Charged Coupled Device), which is translated into "electronic coupling device" in Chinese. It is a device that senses light, just like the film of a traditional camera. It can be imagined as tiny sensing particles that are spread behind the optical lens. When light and images pass through the lens and are projected onto the CCD surface, the CCD will generate an electric current and convert the sensed content into digital data for storage. The more CCD pixels there are and the larger the size of a single pixel, the clearer the collected image will be. Therefore, although the number of CCDs is not the only focus in determining image quality, we can still regard it as one of the important criteria for judging the camera grade. 
 
The playback process reads the captured digital signal data from the memory, and converts it into the signal required by the PC or TV through the decompression circuit and interpolation method. Exposure control is handled by the Timing Generator in the CCD (or CMOS) drive circuit.  
 
81. What is the difference between Holtek and AT series programming? How to convert existing AT series programs to Holtek?
 
   Answer: From the instruction set point of view, ATMEL's AVR series is an 8-bit RISC microcontroller with a total of 118 instructions, while HOLTEK has 63 instructions. To convert AVR's assembly program to HOLTEK's assembly, you need to be familiar with the assembly instructions of both and translate the AVR program into HOLTEK assembly. It cannot be used directly on the HOLTEK chip. If the program is written in C, most of it should be able to be used directly, but the data definition and register definition may need to be changed. In addition, in the programming process, you also need to consider the impact of the differences in the hardware structure of the two on the implementation of the instruction function. Sometimes, due to the difference in hardware, the project may need to be re-planned. 
 
82. Are there any models of Holtek and AT series with electrically erasable FLASH?
 
Answer: Currently, HOLTEK does not have electrically erasable FLASH models. You can use the DICE of the OTP chip or the window film to erase the EPROM with ultraviolet light to achieve multiple programming of the chip.  
 
83. In a product made of MCU, after development is completed and mass production begins, testing is required. However, the tester may not be able to test every part of the software. When writing the program, a special test process is made. When certain conditions are met (such as pressing several keyboards at the same time), the test program is entered. The test program works in a relatively short time. How to achieve this?
 
    A: From the perspective of HOLTEK IC manufacturers, for a finished MCU, once its peripheral devices are connected OK and its MCU chip's basic logic functions run normally, the finished MCU is basically a good product. Because ICs undergo logic and programming tests before leaving the factory, the packaged chips sent to customers are all qualified. Most of the defective chips produced by customers during production are caused by I/O damage (such as ESD damage, high voltage damage). If the IC's I/O logic function runs normally, it means that the IC can run any program, and it is not necessary to test every part of the software to ensure the yield of the finished MCU. Therefore, your test method can already guarantee the yield of the IC.  
 
84. Is there a good way to solve the encryption problem without damaging the MCU?
 
    Answer: The encryption and decryption technology of single-chip microcomputer system products is always a contradictory unity. The protection of scientific research results is the most concerned thing for every researcher, and the purpose is not to let their hard work go to waste. The encryption methods for single-chip microcomputers generally adopt software encryption, hardware encryption, software and hardware integrated encryption, time encryption, error guidance encryption, patent protection and other measures. Where there is a spear, there is a shield, and where there is a shield, there is a spear. Only with the spear and the shield can the quality level of the spear and the shield be improved. Encryption only talks about the use of the shield. The following is a brief description of the encryption method:  
 
Hardware encryption: Make your program unreadable by others.  
 
l High voltage or laser burns out a pin, making it impossible to read the internal program. Using high voltage will cause damage to some devices, that is, permanently destroy the specific I/O of the microcontroller data bus. Even if the decryptor erases the encryption bit, he cannot read the correct code of the program on the chip. In addition, there is a method to destroy the EA pin. 
 
l Important RAM data uses batteries to protect RAM from power failure. That is, first write a series of data into RAM and connect the battery, then insert the rest of the chips. In this way, when the single-chip microprocessor system is running, the CPU first reads data from RAM. This data can be the basis for the CPU to execute the program, or it can be the program that the CPU will execute. If the data is correct, the whole system will run normally. Otherwise, the system cannot run. 
 
l Bus scrambling method. The bus scrambling method usually scrambles the order of the data lines and address lines between the MCU and EPROM. Software encryption: Its purpose is to prevent people from reading your program and modifying the program. You can use DES mixed code to store the important data area of ​​the program first, but when using it, you must cooperate with the external input Decode code (golden key) to decompress it. Or add program machine code to the empty unit without program, it is better to be more clever, etc.  
 
Encryption using true and false methods: (1) Erase the chip logo. (2) Change the DIP package to PLCC, TQFP, SOIC, BGA and other packages.  
 
85. When developing a control system (generator system) that needs to work reliably for a long time, how to design a reset circuit?
 
   Answer: MCU reset can be divided into internal and external event reset. External event reset includes power-on reset, RES reset and low voltage reset. 
 
    Power-on reset and RES reset are normal manual resets to ensure that the program counter is cleared and the program is executed from the beginning. To perform these two reset actions normally, you need to connect a correct RES reset circuit. Generally speaking, the reset circuits of different microcontrollers are slightly different, and microcontroller manufacturers will provide standard reset circuit information. Taking HOLTEK IC as an example, the reset circuit we provide is that the RES pin is connected to a 100K ohm resistor to VDD; the RES pin is then connected to a 10K resistor and a 0.1uF capacitor to VSS. 
 
    When the power supply voltage is affected by external interference and is lower than the normal working voltage, the program function will not run normally, and in severe cases, the microcontroller may crash. At this time, the generator system will cause serious consequences, and we need to use low voltage reset to solve this problem. Usually we can use two methods to achieve low voltage reset: 1. Add a voltage detection chip (such as 7033) to the RES pin. When the power supply voltage is lower than a certain critical value, the voltage detection chip will give a low level to the RES pin to reset the microcontroller and prevent the microcontroller from crashing. 2. Some manufacturers' microcontrollers have a low voltage detection LVR function inside, such as HOLTEK microcontrollers. When the power supply voltage is lower than a certain critical value, the microcontroller will automatically reset to avoid crashes, and no external voltage detection circuit needs to be connected.  
 
   In addition to the external power supply instability causing the microcontroller to reset, the internal WDT overflow will also cause a reset, that is, an internal event reset. For systems that need to work stably for a long time, a watchdog is very necessary, as it can avoid errors caused by program runaway.  
 
    When a reset occurs, to ensure that the reset can be seamlessly connected to the various states before the reset, software is needed to determine which program segment the program is executing to before the reset. Taking HOLTEK MCU as an example, except for the power-on reset, the values ​​of general registers before and after the reset will not change. Then some registers can be set to record which program function segment the program is currently running in. Once a reset occurs, you only need to read the values ​​of those registers to jump to the program function segment running before the reset. In addition, there are two special flags PD and TO inside the HOLTE MCU, and the values ​​of these two bits can be used to determine the specific cause of the reset.  
 
86. From the perspective of enhancing the chip's own interference capability during chip packaging and design, what are some good anti-interference measures? Can shielding technology be added during packaging? Can measures be taken during layout? What issues should be paid attention to in design?
 
    Answer: Generally, each company has its own unique way to deal with the anti-interference inside the IC. For example, the ESD protection circuit is specially used for ESD protection on the integrated circuit. This ESD protection circuit provides an ESD current path to prevent the current from flowing into the internal circuit of the IC and causing damage during ESD discharge. Because ESD comes from the outside, the ESD protection circuit is built next to the PAD. In the output PAD, the large-sized PMOS and NMOS components in the output stage can be used as ESD protection components, but their layout must comply with the provisions of the Design Rules on ESD layout. For example, in traditional integrated circuit design, the power supply and ground are usually arranged on two symmetrical sides. For example, the lower left corner is the ground and the lower right corner is the power supply. This allows the power supply noise to pass through the entire silicon wafer. The improved technology arranges the power supply and ground on two adjacent pins, which reduces the current passing through the entire silicon wafer on the one hand, and makes it easier to arrange external decoupling capacitors on the PCB design on the other hand to reduce system noise. Another example of reducing noise in integrated circuit design is the design of driver circuits. Some microcontrollers provide several high-current output pins, ranging from tens of milliamperes to hundreds of milliamperes.  
 
The integration of these high-power drive circuits into the microcontroller undoubtedly increases the noise source. The softening technology of the jump edge can eliminate this influence. The method is to make a high-power tube into several small tubes in parallel, and then connect a resistor of different equivalent resistance to the output end of each tube in series to reduce di/dt.  
 
87. How to check and confirm whether the microcontroller with WATCHDOG function is working? For example, some microcontrollers will execute RESET only when the program executes HANGUP. How to confirm it?
 
   A: Take HOLTEK's most basic I/O microcontroller HT48R05A-1 as an example. There are PD and TO bits in the microcontroller's special register STATUS, which are readable but not writable. By reading the values ​​of PD and TO, you can determine different reset reasons, such as power-on reset, RES reset under normal operation, RES reset under HALT state, WDT reset under normal operation, and WDT reset under HALT state. Therefore, you only need to determine the values ​​of these two bits to confirm whether the WDT is working. 
 
   If you need the WDT to reset in the HALT (ie HANGUP) state, then you only need to feed the watchdog correctly (ie CLR WDT) during normal operation, and select the internal RC clock as the clock source of the watchdog. When the program enters the HALT state, a reset will occur once the WDT overflows.  
 
88. We want to develop a module that converts synchronous serial port data to Ethernet or USB. Can you recommend a DSP or a current high-speed microcontroller that can support synchronous data and is easier to develop when connecting to network chips such as REltek8139?
 
    A: Generally, choosing a DSP for network multimedia applications is a complex task. First, a comprehensive analysis of the processor's core architecture and peripheral configuration is required. It is important to understand how multimedia data flows (for example, video, images, audio, and packet data) are transmitted in a DSP-based system in order to prevent bandwidth bottlenecks. In addition, it is also helpful to understand various system characteristics (including DMA and memory access), which can make the design stable and reliable, rather than just barely qualified. The choice of network multimedia processor depends on the performance and connectivity requirements of a design. Many applications require both an MCU and a DSP: the MCU provides the system's control functions, and the DSP performs intensive numerical calculations. These distinct functions can be integrated into a single processor, such as the HOLTEK HT82A88F series DSP chip. This device performs full control functions and heavy signal processing tasks in a single architecture, while also providing a variety of peripheral interfaces suitable for multimedia connectivity. 
 
    The first factors that system engineers should analyze when selecting a DSP include: 1. The number of instructions executed per second, 2. The number of operations completed per processor clock cycle, and 3. The efficiency of the operation unit. These indicators can be evaluated by running a set of representative benchmark programs (such as audio/video compression algorithms) on the DSP to be evaluated. The results will indicate whether the real-time processing requirements of the system exceed the capabilities of the DSP, and equally important, whether the DSP has sufficient performance to cope with new or evolving system requirements. Many standard benchmark programs assume that the data to be processed already resides in the DSP's on-chip memory. As long as engineers coordinate the various I/O design considerations, this method can make a more direct comparison of DSPs from different manufacturers. 
 
   In addition, the right combination of peripheral ports eliminates the need for external circuits to support the required interface, thereby reducing development time and cost. Network multimedia devices (NMDs) can be equipped with a variety of standard peripherals. The most important of these is the connection to the network interface. In wired applications, Ethernet (IEEE 802.3) is the most popular choice for networking on a LAN; and IEEE 802.11b/a is becoming the preferred solution for wireless LAN connections. As a direct extension of the DSP, many Ethernet solutions are now available. In addition, for DSPs with good support for microprocessor functions, it can also be used to directly manage the TCP/IP stack. Synchronous and asynchronous (UART) serial ports are also necessary to connect the DSP to the multimedia system environment. In network multimedia device systems, audio encoding data is generally transmitted through 8 to 32-bit synchronous serial ports; while audio/video codec control channels are managed through slower serial interfaces, such as SPI or two-wire interfaces. In addition, UART supports RS-232 modems and can also support IrDATM for short-range infrared transmission.  
 
   There are also many DSPs that support universal interfaces such as PCI or USB, which can bridge different types of devices through peripheral chips, such as PCI to IDE, USB to 802.11b, etc. PCI also has the advantage of providing a separate internal bus, which allows the PCI bus master to send or read data to the DSP memory without going through the DSP core or other peripheral units. In addition, DSPs suitable for the network multimedia device market should include an external memory interface to act as asynchronous and SDRAM memory controllers. The asynchronous memory interface simplifies the connection with flash memory, EEPROM and peripheral bridge chips, while SDRAM provides the necessary storage space for high-density calculations of large-capacity data frames.
 
89. Does the HT48 series MCU support serial communication? Which communication method is more suitable? What is the difference between the structure of the RX/TX two PINs (P3.0/P3.1) of the HT46 series MCU serial communication I/O port PA.67 and 51 series? Are the transmission performances the same? Can you give a keyboard and computer communication routine and general communication protocol?
 
    A: The HT48 series MCU supports serial communication. Serial communication can be achieved by using software programming and the I/O of the HT48 series MCU. On the HOLTEK website, there are software and hardware application examples for using the HT48 series to implement serial communication using "I2C" or "three-wire serial communication" (http://www.holtek.com.cn/tech/tech.htm).
 
    The serial communication ports PA.6/SDA and PA.7/SCL of the HT46 series are shared pins. They can be selected as normal I/O full-duplex input and output interfaces or serial communication ports through mask selection. When used as serial ports, SDA/SCL is the slave end of the I2C communication bus protocol, which is different from the serial communication protocol used by the RX/TX of the 51 series. The TX/RX of the 51 series follows the RS-232 serial protocol. Therefore, the transmission efficiency between them is incomparable.  
 
    If you want to use a single-chip microcomputer to make a keyboard product, it is recommended to use HOLTEK's HT82K68E, which supports the PS/2 interface, or HT82K96E, which supports the USB interface. These chips are designed by HOLTEK specifically for keyboard applications. For specific chip information, please see: http://www.holtek.com.cn/products/mcu_11.htm 
 
90. How can a data transfer rate of 480MB/S be achieved using a 12M crystal oscillator?
 
    Answer: A 12MHz crystal oscillator with integrated PLL can reach 480MHz. The phase-locked loop (PLL) is also called a phase-locked loop or a phase-locked loop. Its principle is to drive the action frequency of another action element with inaccurate action and high frequency variation through the feedback of a closed-loop automatic control system, so that it can quickly and stably maintain the same phase or even the same phase and frequency with the correct frequency reference source. This is the phase-locked state. If we use an oscillation frequency source with extremely low frequency variation outside the circuit as a reference to drive the oscillation frequency source with extremely low frequency variation inside the circuit to achieve a phase-locked state, it can be used as a modulation/demodulation circuit in a communication system. 
 
   The general data transfer rate of 480MB/S is used in USB 2.0. When the Universal Serial Bus specification was released in January 1996, it represented that the industry had successfully developed a low-cost serial channel between peripheral components with medium and low bandwidth and personal computers, but it still lacked the ability to support high-speed broadband applications. In April 2000, USB once again launched a new generation of USB 2.0 technical specifications, which can increase the signal transmission speed by a full 40 times, from the original USB 1.0's maximum speed of 12MHz to the current USB 2.0's high-speed 480MHz, and expanded more advanced functions, such as new transmission devices to improve bandwidth utilization and increase additional functions between transmission devices and host controllers. 
 
    As for the bandwidth that is actually available, the data transmission bandwidth speed has been increased from the original 1 Mbytes/sec to 50 Mbytes/sec. This substantial increase in bandwidth is mainly due to the USB 2.0 specification using new technologies such as micro-frames, transmission packets that can accommodate more information, more frequent transmissions, split transactions, and some new tokens. The USB 2.0 device architecture also adds two new descriptors, namely the Device Qualifier and other speed configurations, which can be used to clearly indicate the functional performance of the data transmission device at other operating speeds. 
 
    Regarding the changes in electronic specifications: the connection between the host and the new high-speed controller is redefined to support the current transmission performance of up to 480MHz. The new high-speed topology standard uses 90W differential characteristic impedance with differential current mode signaling and the same NZRI encoding mechanism, but slightly changes the SYNC signal, EOP signal and idle state. However, it must also be combined with other related specifications to strictly control the stray capacitance, peak to peak jitter and rise/fall time, so that the signal transmission speed can be faster. 
 
91. In microcontroller programming, how to force a return to the main program from a nested high-level interrupt? Can the subroutine return instruction be replaced by a jump instruction to return to the main program after restoring the stack?
 
    Answer: If it is a 51 series, you can directly use the POP instruction to achieve a forced return; if it is a RISC structured microcontroller (HOLTEK microcontrollers are RISC structured), it is generally a hardware stack, without PUSH and POP instructions, so the subroutine call and return instructions must be used in pairs. 
 
92. What are the requirements for the speed of the microcontroller? Can Holtek's microcontroller meet this application?
 
    A: Currently, the maximum speed of HOLTEK's microcontroller is 8MHz, and the execution time of one instruction is 0.5us. At this speed, it can meet the development of most projects; I don't know what specific project you are talking about. Currently, HOLTEK microcontrollers mainly include OTP and Mask. In the future, Flash microcontrollers will be launched; but HOLTEK's development system is very complete. During the development stage, HOLTEK can also provide free samples appropriately. Relatively speaking, the development cost is not higher than using Flash. 
 
93. PSoC is a flexible and powerful software and hardware embedded development system. Can PSoC be used to replace part of the microcontroller system?
 
    A: In general embedded system applications, dozens or even more analog or digital peripheral components may be needed. Engineers familiar with MCU development know that in the process of MCU development, the most time-consuming and energy-consuming thing is the selection of components and the consideration of component compatibility. There are thousands of different peripheral components on the market, and it is a headache for designers to find components suitable for their applications. Therefore, the ideal solution for design engineers seems to be to use customized SoC chips, but if customized microcontrollers, ASICs and PLD devices are used, on the one hand, the price is relatively expensive, and on the other hand, designers need to have specialized design skills. Therefore, it is necessary to develop a high-efficiency, low-power 8-bit microcontroller with embedded configuration of peripheral components. 
 
    PSoC (Programmable System on Chip) is a new generation of powerful 8-bit configurable embedded microcontrollers recently launched by Cypress MicroSystems of the United States. The fundamental difference between this series of microcontrollers and traditional microcontrollers lies in the digital and analog block modules integrated inside. Engineers can call different digital and analog block modules according to different design requirements to complete the functional design inside the chip; use a chip to configure a microcontroller with a variety of different peripheral components, and establish a configurable embedded microcontroller; to achieve the entire process from determining the system function to the software/hardware division and completing the design. Therefore, PSoC can adapt to very complex real-time control needs. Using it for product development can greatly improve development efficiency, reduce the complexity and cost of system development, and enhance the system's reliability and anti-interference ability; therefore, it is particularly suitable for various control and automation fields. Therefore, PSoC's dynamic configuration capability provides developers with a fast and convenient programming and development method, and also opens up a larger space for the application of microcontrollers. Therefore, using the flash memory integrated in the chip can reduce product development costs and shorten product development cycles. Therefore, this MCU structure has broad application and promotion prospects. 
 
94. What initialization operations does the microcontroller need to perform on the modem?
 
Answer: Generally, the MODEM communication of a single-chip microcomputer requires two background knowledge, one is the AT command set, and the other is the Universal Asynchronous Receiver Transmitter (UART). 
 
l AT command set 
 
The following are the AT commands involved in my communication program examples.  
 
Dn: dial command. This command makes the MODEM immediately go off-hook and dial the number that follows. The D command is a basic dial command. It can be modified by other commands to form operations such as when and how the MODEM dials.
 
T: Tone dialing. For example, ATDT8886666, where 8886666 is the phone number.
 
P: Pulse dialing. For example, ATDP8886666, where 8886666 is the phone number.
 
,: Standard pause. We often need to pause when dialing an external line, and wait until we hear the secondary dial tone (external line) before dialing the subsequent number. The default pause time is 2s (seconds), which is specified by the S8 register.
 
Sn: indicates the register inside the MODEM.
 
S0: Automatic response. If the MODEM is required to have the automatic response feature, the S0 register of the MODEM should be set to non-zero in advance.
 
S8: Pause time of comma dial modifier. This register determines the time the MODEM should pause when it encounters a comma (,) in dialing.  
 
l Universal Asynchronous Receiver Transmitter UART
 
    A deep understanding of the internal structure of UART and the meaning of each bit of the internal register, as well as a detailed understanding of the process of sending and receiving data, will help you write efficient and stable programs. This article generally introduces the registers you need to know when writing basic communication programs. The actual ADDRESS is determined by the specific wiring. 
 
l Serial transfer rate divisor latch (LSB, MSB)  
 
    Before communication, some parameters need to be initialized, and the serial transmission rate is the first item that should be considered. This register is a 16-bit register, divided into the lower 8 bits (LSB) and the upper 8 bits (MSB) register.  
 
    In addition, the microcontroller accesses the serial transmission rate divisor latch LSB/MSB. The commonly used operating frequency is 1.8432MHz. This frequency divided by 16 is the serial transmission rate clock frequency, which is used to control the speed of sending and receiving data.  
 
The following is the calculation formula for the serial transmission rate divisor latch value:  
 
Serial transfer rate divisor latch value = operating frequency / (16 × expected serial transfer rate) = 1843200 / (16 × expected serial transfer rate)
 
l Receive buffer register and send holding register (transmit and receive holding register)
 
The microcontroller accesses the receive buffer register (RHR) for read operations and the transmit holding register (THR) for write operations.  
 
l Interrupt enable register  
 
l FIFO control register  
 
The selection of data sending and receiving modes. There are two commonly used modes: FIFO and DMA. Among them, DMA has two modes: DMA mode 0 and DMA mode 1. 
 
95. The microcontroller I use is AT89C51. I have tried to use the pop instruction to force the interrupt to return. It can indeed return to the main program. The specific method is: first pop the address in the stack, then push the new address in the main program, and finally execute the RETI instruction to return to the address. If the jump instruction is used directly after the pop instruction is executed without the RETI instruction, it can also return to the main program, but it will not be able to respond again when the next interrupt comes. How to return to the main program from the nested high-priority interrupt program? Do I have to go through the lowest-level interrupt to return? If I return directly, can I still respond normally to the next interrupt?
 
    Answer: For the 51 series MCU, when the middle response occurs, the corresponding priority valid trigger will be set; when exiting the interrupt, RETI is executed, and the MCU automatically clears the priority valid trigger to 0. Therefore, if the jump instruction is used directly to exit the interrupt subroutine, the MCU does not clear the priority valid trigger to 0, and cannot respond when the next interrupt occurs. 
 
    If you want to return to the main program from a high priority interrupt program, you must execute two RETI instructions to clear the high/low priority valid trigger. The specific program can be:  
 
MOV DPTR, #LABLE1
 
POP ACC ; Pop the high priority subroutine return address from the stack
 
POP ACC
 
PUSH DPL; push LABLE1 address onto the stack
 
PUSH DPH
 
RETI
 
LABLE1:
 
POP ACC ; Pop the low priority subroutine return address from the stack
 
POP ACC
 
MOV DPTR, #LABEL2
 
PUSH DPL; push LABLE2, the main program address to be returned, onto the stack
 
PUSH DPH
 
 
 
RETI
 
Reference address:Many questions about single chip microcomputer

Previous article:MSP430 Assembly Instructions
Next article:How the program is debugged in RAM and how it is run after being solidified

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号