The 51 series single-chip microcomputer instruction shorthand method proposed by experts

Publisher:xinyi9008Latest update time:2013-02-05 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Expert advice

  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.

Reference address:The 51 series single-chip microcomputer instruction shorthand method proposed by experts

Previous article:Some misunderstandings and precautions of C51
Next article:Small production of colored lights based on single chip microcomputer

Recommended Content
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号