In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to use keil programming C language, the editor feels very practical, so share with you to learn, I hope you can learn something after reading this article, do not say much, follow the editor to have a look.
Single-chip microcomputer needs to use C language as a program to send instructions to it, and single-chip microcomputer needs hex type files of C language for transmission. KEIL is one of the excellent software in many single-chip microcomputer application development software, and can generate hex files. It supports the chips of MCS51 architecture of many different companies. It integrates editing, compilation, simulation and programming in PLM, assembly and C language.
Next we can try to use keil to program C language.
1. The first step is to open the keil software, and the interface displayed after opening is as follows.
2, click "Project" as shown in the first picture below, and then click new uVision project, and the interface shown in the third picture below will appear; fill in your project name in the file box, which can be composed of any English characters (at this time you'd better create a new folder in the place where you want to store the project, as shown in the second picture is to set up a test folder on the desktop to store the new project).
3, after entering the name of the project, the chip selection dialog box shown in the following figure will appear, and you can select the model on your development board (I believe the reader who wants to see this post must be learning 51 single-chip microcomputer, at this time, just select Atmel, and then click AT89c51. As shown in the second picture below).
4. The following picture will appear, which is a piece of assembly code executed before jumping into the C function. If you don't add it or use the default startup code, if you don't modify it, it's the same as using the default startup code.
For example, if you want to set the value of SP separately, you can add it without default, and then modify SP.
Anyway, this startup code does not need to be changed, it does not matter whether it is added or not.
Decide whether to add or not according to the needs of your project.
If you use assembly language to write the program, it is recommended not to add it, but also have to change the name of the module, please.
If you use C language, it's good to add it so that you don't forget some initialization work.
5. Next, the first picture below appears, first click the New File, and then click the Save button.
6, click the Save button to appear the dialog box shown in the first picture below, enter the source file name with the suffix name (if you are writing the program in C language with the suffix name of * .c; if you are writing the program in assembly language, the suffix name is * .asm) and click to confirm save. After confirmation, the interface is shown in the second picture below, and notice the change in the place indicated by the arrow.
7. The next step is to add the source file to the project. Click to select "Source Group 1" (source group) and right-click. The interface shown below will appear.
8. Click add File to Source Group 1 (Add files to.) ); as shown in the arrow in the first picture below. Click will bring up the dialog box shown in the second picture, in this dialog box, just click to select the fifth saved source file and click Add (note the changes before and after clicking on the source file, and especially note that there is no change in the interface after clicking Add, you just need to close the dialog box).
9. After opening source group, there will be the changes indicated by the arrow in the following figure.
10. Write the program in the source file input box on the right, and click the compile button shown in the figure.
As shown in the following figure, you can see that the program is error-free and compiled successfully. However, we click to enter the project folder and do not see the suffix .hex file, as shown in the following figure.
12. So we need to click the goal 1 button to set it, as shown in the first picture below. Click again to set options for goal 1
13. Click the output option shown in figure 1 below in the dialog box, and check create hex file to show it in figure 2 below. Check the box and close the dialog box and compile it again as in step 10. You can see that the .hex file is generated in the folder.
The above is how to use keil programming C language, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.