I tried to port the STM Keil project to IAR several times. Fortunately, all of them succeeded. Here I will write down the notes during the porting process...
The first step is to first create a project folder PWM, and then create several subfolders in the folder: User, Inc, and startup. Of course, we have to copy the official library directory of STM, so there are four folders under the project directory (in fact, creating a few folders is random, just follow the habits, you can also create the corresponding folder for the Keil project ).
Step 2: copy the files in the Keil project to the project directory you just created *. c files are all stored in the user directory ,*. H files are stored in the INC directory, and the startup Assembly file is placed in the startup directory (in fact, this file is stored in the official library directory, so this startup directory can also be left empty ).
Step 3: Start IAR. IAR has a workspace. There is no specific research on this, I only want to file-> New-> workspace and then project-> Create new project, of course, designated to the project directory just created. Then add several groups, user, Inc, startup... and add files to it.
The fourth step is to set up the IAR project. The previous figure first (indicating dissatisfaction... I tried several times and couldn't upload it !!! Forget it ). The setting mainly involves selecting the corresponding device in target of general options. For example, I chose stm32f407zg, And the Preprocessor option in C/C ++ compiler has an additional include directories. it will be okay to write the header file path into it, however, it should start with $ proj_dir $ (in fact, this is to set the current path as the project directory, that is, the directory specified when saving the project in step 3 just now... \ PWM). For example, I have put all the header files in the INC directory for the project I just created, so I wrote
$ Proj_dir $ \ Inc (assume that a project directory has been created and the project is saved to this directory in step 3, then $ proj_dir $ is the \ PWM \ project directory, the header file path has to be slightly modified. The INC directory and project directory are in the same level directory, so we should write $ proj_dir $ .. \ Inc ".. "indicates the upper-level directory of the current directory, which is better understood if Linux is used ). Similarly, it's okay to write all the header file paths of the official library file, and my settings are as follows:
$ Proj_dir $ \ Inc
$ Proj_dir $ \ libraries \ cmsis \ include
$ Proj_dir $ \ libraries \ cmsis \ device \ ST \ stm32f4xx \ include
$ Proj_dir $ \ libraries \ stm32f4xx_stdperiph_driver \ Inc
Next, I didn't set the preinclude option at the beginning, but it was empty. Many errors occurred during the compilation of the result. At first glance, some header files were not included, this option is the header file that is included before compilation. I specified the path of the D: \ F4 PWM \ User \ stm32f4xx_conf.h file in it (this file contains all the calls to the official library files) So ...... Now that everything is okay, linker and debugger will not talk about anything!