Quick tips, teach you how to use Keil C51 software in three minutes

Publisher:DreamyEclipseLatest update time:2024-01-26 Source: elecfansKeywords:Keil Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

Quick tips, teach you how to use Keil C51 software in three minutes

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.

Quick tips, teach you how to use Keil C51 software in three minutes

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.

Quick tips, teach you how to use Keil C51 software in three minutes

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.

Quick tips, teach you how to use Keil C51 software in three minutes

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

Quick tips, teach you how to use Keil C51 software in three minutes

After creating a new file, the screen is as shown below

Quick tips, teach you how to use Keil C51 software in three minutes

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.

Quick tips, teach you how to use Keil C51 software in three minutes

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

Quick tips, teach you how to use Keil C51 software in three minutes

Then click "Add File to Group 'Source Group 1'" The screen is as shown below

Quick tips, teach you how to use Keil C51 software in three minutes

Select Test.c and click "Add" as shown below

Quick tips, teach you how to use Keil C51 software in three minutes

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

Quick tips, teach you how to use Keil C51 software in three minutes

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

Quick tips, teach you how to use Keil C51 software in three minutes

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

Quick tips, teach you how to use Keil C51 software in three minutes

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?

Quick tips, teach you how to use Keil C51 software in three minutes

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.


Keywords:Keil Reference address:Quick tips, teach you how to use Keil C51 software in three minutes

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

ads+jlink and keil+jlink debugging environment configuration
/***************************************************************************************************************************************************************************/ ads1.2 and jlinkv8 1. Install ads1.2 and jlink driver Setup_JLinkARM_V408i.exe When installing ads1.2, if it takes a long time to reach 100%, be
[Microcontroller]
Analysis of the support of dual data pointers in Keil C51
In the 8051 system, the data pointer DPTR is a special 16-bit register used to address the 64 KB XDATA or CODE space. It is usually used as a 16-bit pointer to a constant table. Dual data pointers can improve the performance when two 16-bit pointers are used at the same time. As an enhanced feature, many 8051 deri
[Microcontroller]
Analysis of the support of dual data pointers in Keil C51
A full range of solutions to the "Target not created" problem in KEIL5 compilation - Case 2
Preface When programming in KEIL5, you often encounter many "Target not created", that is, the target cannot be achieved. Therefore, this post is opened to help everyone solve these problems. The directory is as follows: 1. 2K byte limit error ERROR: RESTRICTED VERSION WITH 0800H BYTE CODE SIZE LIMIT or ADDRESS SP
[Microcontroller]
A full range of solutions to the
mini2440---Building the debugging and downloading environment under keil for ARM
Off-topic: Recommended compilation environment selection For those who are new to ARM bare metal programming, I would like to remind you about the choice of compilation environment. Currently, there are three mainstream ones: ADS+AXD, KEIL FOR ARM, and IAR FOR ARM. I started using ADS+AXD for learning because it com
[Microcontroller]
Keil C51 extends C language's keyword 14: interrupt
8051/8052 series microcontroller standard vector table: Interrupt number       describe    address              0 External interrupt 0  0003h 1 Timer/Counter 0  000Bh 2 External interrupt 1  0013h 3 Timing counter 1  001Bh 4 Serial Port  0023h 5 Timer Counter 2 (8052)   002Bh Many manufacturers have added
[Microcontroller]
Keil C51 project establishment
When using Keil software, it is in the project created by the software, so create a project: start the journey of program development: 1. Open Keil software, click Project---new project 2. Select a suitable folder in the pop-up dialog box, give the project a name--you can use any name, of course, in order to manage
[Microcontroller]
Keil C51 project establishment
Keil C51's Keyword Extensions to C Language 12: _priority_ and _task_
The Keil 51 compiler supports the RTX51 Full and RTX51 Tiny real-time multitasking operating systems, and provides them with the _task_ keyword and the _priority_ keyword. The _task_ keyword indicates that a function is a real-time task. The _priority_ keyword indicates the task priority. Example: void func (v
[Microcontroller]
STM32 study notes--establishment of keil project
1. The functions of the three buttons compiled by Keil A. The first button: Translate translates the currently modified file. To put it simply, it checks for syntax errors. It does not link library files or generate executable files. B. The second button: Build is to compile the currently modified file, which includes
[Microcontroller]
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号