Programming Method of MCS-51 Single Chip Microcomputer

Publisher:梦幻微笑Latest update time:2015-03-20 Source: diangonKeywords:MCS-51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  Programming is a link in the process of using computers to solve practical problems. The process of using computers to solve practical problems includes two stages: establishing mathematical models, selecting calculation methods, designing programs, debugging on the computer, running programs and analyzing calculation results. After analyzing a specific problem, we can derive the relationship between input and output quantities and describe it with mathematical formulas. This process is called establishing a mathematical model. With a mathematical model, we must also select a specific calculation method suitable for computer implementation, and then design a program. Programming is actually the implementation of a specific algorithm. The designed program also needs to be debugged in a certain debugging environment. At this time, data should be input and the output data should be checked to see if it is correct. In order to ensure the correctness of the problem, reasonable input data should be designed to check possible errors in the program.

  The programming of MCS-51 microcontroller is usually divided into the following three steps:
  1. Make a program flow chart
  Find the most reasonable and simplest solution for the proposed algorithm and make a program flow chart. The program flow chart shows people's ideas of using a certain algorithm to solve the problem. There are two types of flow charts: rough and detailed. The rough flow chart can give the general steps of solving the problem, while the detailed flow chart gives the details of each step. For some big problems, a rough flow chart should be given first to get the overall concept, and then a detailed flow chart should be made to give a specific description of each step.
  2. Resource allocation
  Reasonably allocate system resources according to the requirements of the algorithm, such as memory allocation, input and output interface allocation, etc. In the MCS-51 system, program and data memory are addressed separately, and the memory is divided into internal and external memory, and there is also bit-addressed memory. Therefore, reasonable resource allocation will bring convenience to programming, otherwise it may increase trouble and even cause program errors.
  3. Source Programming and Debugging
  Source programming is to implement the algorithm expressed in the flow chart with a program. The program of the MCS-51 system can be edited with an editor, read in the integrated debugging environment, or directly input in the integrated debugging environment. The integrated debugging environment includes debugging tools for the program, such as single-step, breakpoint, full-speed program running, and register checking, memory content checking and other functions.
  Among the above steps, making a program flow chart is an important step in program design. In complex problems, it can help designers find the best solution and reduce errors in the source program writing process; it can also help find errors in the debugging process. It is also a concise explanation of the source program, which is easy to retain and communicate. Usually we should make a program flow chart first and then compile the source program.

Keywords:MCS-51 Reference address:Programming Method of MCS-51 Single Chip Microcomputer

Previous article:Design of MCS-51 Single-Chip Microcomputer System Program
Next article:The role of pull-up resistor in 51 single chip microcomputer

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号