1. How to create a new arm project

Source: Internet
Author: User

Learning Stm32, the first step is to choose the development tools, Gcc,mdk,iar each has its own advantages and disadvantages, no longer repeat. Here, I choose to use the time MDK5.14. For the first time using MDK, if there is a development board, then the routines provide a lot of templates for us to learn. But I found that the direct use of these templates, although it makes me quick to implement the function, it is very interesting, but the parsing of the code makes me feel confused, I do not even know the program's running flow, and do not know why the design, so I have a break out of the routine, the idea of building their own, the first build the wrong bunch Through Baidu and their own find to solve this mistake cost me nearly 4 hours, I put my entire experience recorded, although the future experience of the chip or development software may be different, but the specific ideas are consistent. This process is also basically applicable to all uses of MDK generation for STM32 programs (firmware function library mode). In order to be able to resolve the same error again later, I will give you the detailed steps as possible.

Preparatory work

To create the project folder, add the Output,source folder below it (below):

Then add the folder app under the source folder to hold the user files.

Note: All folders (including folders on the project path) must be in English, because in some cases an unknown compilation error occurs.

Move the header file in the standard library file and the corresponding sub-file code to the source folder, I use stm32f10x_stdperiph_lib_v3.5.0, the subsequent library may have other changes, which requires you to follow this idea to deal with, decompression stm32f10x_ Stdperiph_lib, find the \\stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries folder.

and copy it to ... \ \ Project folder (current project, English) under the \\SOURCE folder, where Cmsis is the cortex microcontroller software interface standard, it provides stm32 startup files, peripheral definitions, and device definitions. What Stm32f10x_stdperiph_driver provides is that the library function is used to implement the operation of the chip.

The SOURCE folder contents are as follows:

To this, the whole project preparation work is done, the following began to use MDK to establish the project.

Building a project using MDK

1. New Arm MDK Project, I chose the chip Stm32f107vs, and the Development Board chip consistent, position under the current project file. Project establishment, add the corresponding chip but do not add the boot code, manually copy the installation directory \\Keil\ARM\Startup\ST folder stm32f10x.s (boot file, will be explained later) to the current project folder, and added to the current project start_up.

2. Create a new file, save in the above ...//app folder, the file name is saved as MAIN.C and then added to the user folder.

3. Add a folder drive to the project and use the driver file, i.e. ... \source\stm32f10x_ stdperiph_driver\src The driver file you need to use to add to the drive folder, as follows:

Add Inc query support to target for header file lookup.

Note: Important, otherwise MDK is unable to identify the header file you included

The steps are as follows:

1. Select the target folder in MDK, right-click the option (shortcut key Alt+f7), and select C + + on top of the popup dialog box.

2. Add at includepathe at the bottom of the dialog: The current project folder \source\stm32f10x_stdperiph_driver\inc provides header file support (add new support after order), that is, the path of the used header file is included in the software!

Compiling and correcting

After the above is complete, and then the main function to add code, the header file is # include "Stm32f10x.h", compile.

This will appear

C:\Keil\ARM\Inc\ST\STM32F10x\stm32f10x.h (8319): Error: #5: Cannot open source input file "stm32f10x_conf.h": No suchfile or directory

Stm32f10x_conf.h is the statement of the head file of the peripherals used and the internal assert processing command, in the 3.5 Solid State Library I did not find this header file, so I downloaded a header file with all peripheral header file Stm32f10x_conf.h, Put it in the current project folder \source\stm32f10x_stdperiph_driver\inc, continue compiling, there is a bunch of ports undefined, this is because stm32f10x_ Conf.h Although added, but not really enabled, in the Stm32f10x.h to find, about 100 lines of location

Cancel the comment that #defineuse_stdperiph_driver this sentence, such as can. In addition, #include "stm32f10x_conf.h" is defined at the end of # include "Stm32f10x.h",

The following is stm32f10x_conf.h this header file.

It contains all the peripherals you need to use the header files, you need to use what peripherals to cancel the corresponding header file comments.

In addition, if it appears

C:\Keil\ARM\Inc\ST\STM32F10x\stm32f10x.h: Error: #35: #error directive: "Please select first the target stm32f10x Device used in your application (in stm32f10x.h file) "

Indicates that you do not declare the current selection of the STM chip belongs to the type, in the stm32f10x.h find the following code snippet, below will be an English note to tell you how to choose, cancel out your board model corresponding type of comments can (important, the board model corresponding register settings will be different, Select the non-conforming possible program can not run up), such as stm32f107 is connected type, then uncomment the STM32F10X_CL.

To solve the above problems, then an error-free foundation of the arm engineering architecture has been established, of course, to achieve the desired function, but also need to add the relevant code, the next step in the introduction of peripherals I will explain!

1. How to create a new arm project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.