The KEIL C51 standard C compiler provides a C language environment for software development of 8051 microcontrollers. However, many beginners whose interface is in English are confused after reading many tutorials. This site has specially produced a relatively simple tutorial. It can embed assembly language and retain the efficient and fast characteristics of assembly code. The functions of the KEIL C51 compiler are constantly enhanced, allowing you to get closer to the CPU itself and other derivatives, and its efficiency has reached a very high level. C51 has been fully integrated into uVision2's integrated development environment, which includes: compiler, assembler, real-time operating system, project manager, and debugger. uVision2 IDE provides them with a single and flexible development environment.
Keil C51 software is one of the many excellent software for microcontroller application development. It integrates editing, compilation and simulation. It supports assembly, PLM language and C language programming. It has a friendly interface and is easy to learn and use.
The following introduces how to use Keil C51 software
After entering Keil C51, the screen is as shown below. The editing window will appear after a few seconds
Screen when starting Keil C51
Enter the editing interface of Keil C51
The best way to debug simple programs, learn a programming language, and learn a certain programming software is to directly operate and practice. The following will guide you through simple programming and debugging to learn the basic usage of Keil C51 software and basic debugging skills.
1) Create a new project, click the Project menu, and select the New Project option in the pop-up drop-down menu.
2) Then select the path you want to save, enter the name of the project file, for example, save it to the C51 directory, the name of the project file is C51 as shown in the figure below, and then click Save.
3) A dialog box will pop up, asking you to select the model of the microcontroller. You can choose according to the microcontroller you are using. Keil c51 supports almost all 51-core microcontrollers. I will use the Atmel one that is used more often. 89C51 will be used to illustrate, as shown in the figure below. After selecting 89C51, the right column will provide a basic description of this microcontroller, and then click OK.
4) After completing the previous step, the screen will look like the picture below
So far, we have not written a program, let's start writing our first program. 5) In the picture below, click the "File" menu, and then click the "New" option in the drop-down menu
After creating a new file, the screen is as shown below
At this time, the cursor flashes in the editing window, and you can type the user's application. However, the author recommends saving the blank file first, clicking "File" on the menu, and selecting the "Save As" option in the drop-down menu. , the screen is as shown below. In the edit box on the right side of the "File Name" column, type the file name you want to use. At the same time, you must type the correct extension. Note that if the program is written in C language, the extension must be (.c); if the program is written in assembly language, the extension must be (.asm). Then, click the "Save" button.
6) After returning to the editing interface, click the "+" sign in front of "Target 1", then right-click on "Source Group 1", the following menu will pop up
Then click "Add File to Group 'Source Group 1'" The screen is as shown below
Select Test.c and click "Add" as shown below
Did you notice that there is an extra subkey "Text1.c" in the "Source Group 1" folder? The number of subkeys is the same as the number of added source programs.
7) Now, please enter the following C language source program:
#include "reg52.h" //Include file #include "stdio.h" void main (void) //Main function { SCON=0x52; TMOD=0x20; TH1=0xf3; TR1=1; //This line and above 3 lines are necessary for the PRINTF function printf ("Hello I am KEIL."); //Print program execution information
printf("I will be your friend.");
while(1);
}
When entering the above program, readers have already seen the benefit of saving files to be edited in advance, that is, Keil c51 will automatically identify keywords and prompt the user to pay attention in different colors. This will reduce the user's mistakes and is beneficial to Improve programming efficiency. After the program input is completed, as shown in the figure below
8) In the picture above, click the "Project" menu, and then click the "Built Target" option in the drop-down menu (or use the shortcut key F7). After the compilation is successful, click the "Project" menu again, and in the drop-down menu Click "Start/Stop Debug Session" (or use the shortcut key Ctrl+F5), the screen is as shown below
9) Debugging the program: In the picture above, click the "Debug" menu, click the "Go" option in the drop-down menu, (or use the shortcut key F5), then click the "Debug" menu, and click "Go" in the drop-down menu. Click the "Stop Running" option (or use the shortcut key Esc); then click the "View" menu, and then click the "Serial Windows #1" option in the drop-down menu, you can see the results after the program is run, the results are as follows As shown in the picture
At this point, we have completed the entire process of a complete project on Keil C51. But this is just a pure software development process. How to use the program downloader to see the results of the program running?
10) Click the "Project" menu, and then click " " in the drop-down menu. In the picture below, click the "Create HEX File" option in "Output" to compile the program to generate HEX code for use by the downloader software. . Download the program to the AT89S51 microcontroller.
Previous article:Sharing of data storage format and programming skills of C51 compiler
Next article:Ultra-large capacity memory K9F2G08U0M and its application in pipe diameter gauge
Recommended ReadingLatest update time:2024-11-23 06:43
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Single-chip microcomputer C language programming and simulation
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Single chip microcomputer control technology (Li Shuping, Wang Yan, Zhu Yu, Zhang Xiaoyun)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Review Weekly 20220913: Infineon's revolutionary photoacoustic spectroscopy (PAS) CO2 sensor, free application~
- Micro ESP8266 Temperature and Humidity Sensor
- Some Discussion on RF Receiver Noise
- [Shanghai Hangxin ACM32F070 development board review] 6. Transplant the RTX operating system
- After you buy a new mobile phone, what do you usually do with the old one?
- High-Speed Comparators FAQ
- Study on Shear Strength of Sn-Ag-Cu Solder Joints in Microelectronic Packaging
- I'm begging for the full datasheet of the Marvell 88e6171/6175 switch chip
- [Vote] Is it harder to read code or write code? Let’s talk about it
- 51 MCU Application