When you first start learning microcontrollers, you must understand some digital circuits. If you are not familiar with the general concepts of digital circuits, you should learn digital circuits before learning microcontrollers. There are many types of microcontrollers at present, and their structures and instructions are different, so it is best to choose one type of microcontroller to learn first, and then learn other types. If you learn one type for a few days and another type for a few days, you will often not be able to digest it. It is recommended that you first learn 8051 microcontrollers, because there are many books, materials, and equipment about 8051. Although PIC, AVR and other types of microcontrollers have their advantages, unlike 8051 microcontrollers, the supply of books, materials and devices about them is not ideal, and they are not suitable for beginners. If you don't care about these, you can also choose the latter to learn, as long as you think it is suitable for you to learn.
There are many derivatives of the 8051 series, which is why it is recommended that you learn the 8051 microcontroller first. For example, the AT89C51 series microcontroller of ATMEL is fully compatible with the MSC-51 8051 series (that is, the instructions, pins, internal main structure, and usage of the AT89C51 are the same as those of the MSC-51). It is not only compatible, but also has many innovations, such as its program memory can be electrically erased and written. One IC has the smallest system of the past microcontroller, and does not require the previous 373 and EPROM components. Therefore, it is relatively easy to connect the circuits and make the circuit boards during the experiment, and the price is relatively low at present. In addition, the chips you learn can also be used to make products, and the chips used to make products can also be used for experiments. Of course, the AVR series also has these characteristics, but PIC and other series are not ideal in this regard.
When you buy books on microcontrollers, it is best to choose books that you can understand at the beginning but not at the end, because a book that you cannot understand at the beginning and end will not be of much use to you in a short period of time. Of course, you don’t need to use books as references, and you don’t need to buy books that you can understand at the beginning and end, because they are too simple and easy for you to understand. You should focus on books on principles, and then buy some books on applications for reference.
Electronic technology itself is complementary to experiments. It is difficult to understand its principles and learn single-chip microcomputer development by reading books alone. At this time, in order to learn single-chip microcomputers well, you should purchase related single-chip microcomputer chips, programmers, experimental boards, and related software for developing them. It is more effective to combine theory and practice by reading books and doing experiments at the same time! Since it is impossible to purchase a lot of expensive equipment for beginners, it is recommended to purchase single-chip microcomputer chips whose program storage can be repeatedly erased and written for learning, such as AT89C series or AVR series. In this way, there is no worry when learning to burn (program).
Next, let's talk about the steps of MCU development. In order for the MCU to complete a task according to your idea, you must first write a program for it to run. The program for the MCU should be written in a "language" that the MCU can recognize. Otherwise, no matter how perfect the program is, it will be useless for the MCU. Currently, the more popular languages are assembly language and C language. Assembly language can accurately control every step of the MCU's work, while C language focuses on the results and does not care about every specific step of the MCU. It is customary to learn assembly language first and then C language, so that you can have a deeper understanding of the MCU. Moreover, programming in C language requires embedding assembly statements when precise control is required, which is more troublesome. Of course, some people use C language from the beginning and learn assembly language later; if you have learned Turbo C (fast C compiler) for computers, then learning C language for MCU may be faster.
The MCU program is a plain text file written in a text editor. Just like writing a plan in Chinese in Windows Notepad, write this thing first and then that thing, and write down the things that the MCU needs to do "one by one" in the syntax of the MCU language used according to our ideas. If you encounter "some things" that are repeated, indicate where there are instructions (jump); if other emergencies occur during the normal schedule, you must write a plan for handling emergencies (interrupt)... ...The extension of the saved file should also be consistent with the name required by the language used. The Chinese articles in the Notepad are generally saved with the extension *.txt, while the file extension of the assembly language should generally be saved as *.asm. Some development systems have their own regulations. For example, the extension of the assembly program written using the Keil C51 development system is *.a51. Of course, the Keil C51 development system also has its own editor, so you don't have to use the Notepad in Windows.
Whether the program is written in assembly language or C language, the written program is not only for us to read, but also must be compiled by the software corresponding to the language from the assembly language or C language that we can understand into the code that can be recognized by the microcontroller used. Then the code that can be recognized by the microcontroller is burned into the microcontroller program memory, so that the actual circuit installed in the microcontroller can work according to your "plan".
For 8051 series microcontrollers, Keil C51 development system has the functions of editing, compiling and simulating microcontroller C language programs, and can also edit, compile and simulate assembly language programs. For beginners, it is inevitable that syntax errors or other non-standard statements will appear when they start to write programs. Since Keil C51 prompts the error statements in English during compilation, it is difficult to understand. If you use assembly, you can use the macro assembly compiler ASM51 under DOS, which can prompt the error statements in Chinese, and the comment part of the source program can also be in Chinese, which provides you with a lot of convenience in future maintenance of the program.
The compiled code usually has an extension of *.hex or *.bin. This code file must be sent to the microcontroller so that the microcontroller can work according to your "plan" in the circuit. The tool to send this code file to the microcontroller is the programmer. The programmer connected to the computer is generally connected to the programmer's hardware through a parallel port or a serial port, and there is also a corresponding service program. After connecting the computer and the programmer, run its service program, first select the microcontroller model to be programmed in the service program, then call in the code file obtained above, and then use the programmer to burn this code file into the microcontroller. At this point, the process of microcontroller development is roughly completed.
Of course, for beginners, it is impossible to write your "plan" correctly and perfectly in the language of the single-chip computer at once. At this time, you need to modify the source program repeatedly, compile and burn it into the single-chip computer repeatedly, and install the single-chip computer into the circuit repeatedly for experiment. Because the time taken by the single-chip computer to execute each statement is very short, so that you sometimes cannot get the intermediate results, and cannot determine the specific location of the program error, then you can use the software simulation method to let the program execute step by step. At each step, by checking the changes of each key data in the single-chip computer, you can find the error or the statement that is not executed according to your "plan", so as to achieve the purpose of eliminating the error. If you have sufficient funds, you can also buy a single-chip computer simulator, which can well replace the single-chip computer in the actual circuit, and debug step by step under the control of the computer. In fact, whether it is software simulation (emulation) or hardware simulation, its function is far more than this.
Previous article:Some misunderstandings and precautions of C51
Next article:Small production of colored lights based on single chip microcomputer
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- VICOR DCM2322 isolated regulated DC-DC converter is now available for free!
- Zigbee learning notes---protocol stack NV operation
- Required selection: 1.5V lithium rechargeable button battery Rated voltage (V) 1.5V
- GD32E231 analog IIC driver LSM6DSO
- Single Voltage Reference vs. Dual Voltage Reference - I
- Basic C language programming specifications for microcontroller development
- [N32L43X Review] 2. Simulating I2C to drive OLED
- I'm stuck while learning about op amps and have encountered several problems, as shown in the picture. Forum friends who know the answer please help me analyze it. Thank you.
- DDR2 Specification Chinese Version.pdf
- Video demonstration, how to quickly implement the drive test of ST sensor (LSM6DSOX) through STM32 microcontroller