Keil5 new STM32 project

1. Download the official ST library

      First register an account and log in, then click on the product, microcontroller; as shown in the figure


        Then the tools and software on the right; embedded software, and select STM32, as shown in the figure.


  Mine is the STM32F1 series, choose this

    Get the software


    Then download it.


 Two, install keil

    Do not introduce. I believe they are all installed.


3. Preparation

      

  Create a new project folder, and create three new folders in it, CMSIS (store kernel functions and startup boot files), FWLIB (store library functions), and USER (store user's own functions), as shown in the figure.


     Unzip the downloaded official library, the two marked are mainly used.


    Copy the files in STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport to CMSIS, and then copy all the files in C:STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x to CMSIS. The final CMSIS file is shown in the figure.


        Copy the inc src in STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\STM32F10x_StdPeriph_Driver into the FWLIB folder.


   Copy these files in STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template into USER,


      So far the preparation is over.


Four, new construction


  Open keil, create a new project temp (there is a project that needs to be closed), and save it in the newly created project.


        After saving, the chip will be selected. I used the STM32F103VE series, so I chose this one.


        After confirming, a window will pop up and turn it off directly (this is to choose to start the boot, etc., we have already downloaded the library, so skip this step). Click the red circled graph, and then change tegart1 to temp. Delete SourceGroup1.


    Add CMSIS, USER, FWLIB, STARTUP in turn, and add the files just copied under the corresponding folder. Note that STARTUP should select startup_stm32f10x_hd.s, startup_stm32f10x_ld.s, startup_stm32f10x_md.s in NewProject\CMSIS\startup\arm. Select all file types. In FWLIB, you only need to add the .c file in src. There is no need to add files in STARTUP in CMSIS. After adding, click OK.


    Then click the magic wand to enter the C/C++ setting interface, enter STM32F10X_HD, USE_STDPERIPH_DRIVER in the define column, and add the header file path in the includepath column.


           includepath content is as follows


        At this point, the project is created. You can click Compile to see if there are any errors.


Five, problems and debugging

  An error was found after compilation, because the main function in the library used directly does not include the #include "stm32_eval.h" header file, so delete it directly. And delete the unused content in other main functions, and include related header files in the main function. The main function of the blank project is shown in the figure.


 In compiling, there are still errors.


It means that there are too many boot files. That is, only one guide can be used in STARTUP. Because of the HD used here, tick off the gray checkmarks of include TargetBulid and Always Bulid in the other two Options for File.


       After the change is completed, there are red bars in front of the other two in STARTUP.

                                           


Compile again, there is still an error.


    It is said that system_stm32f10x_1.c and system_stm32f10x.c are duplicated.

    However, system_stm32f10x_1.c is not found in the check project column . Finally, it was found that there was a duplication in the include file. Click on the box as shown in the figure and find that system_stm32f10x_1.c is included in both CMSIS and USER . Delete system_stm32f10x_1.c in CMSIS . Compile without errors.



    This article is transferred from the cheaper blog, the original link: https://blog.csdn.net/cheapter/article/details/80198168?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-9.control&depth_1-utm_source=distribute.pc_relevant. none-task-blog-OPENSEARCH-9.control .



        

1. Download the official ST library

      First register an account and log in, then click on the product, microcontroller; as shown in the figure


        Then the tools and software on the right; embedded software, and select STM32, as shown in the figure.


  Mine is the STM32F1 series, choose this

    Get the software


    Then download it.


 Two, install keil

    Do not introduce. I believe they are all installed.


3. Preparation

      

  Create a new project folder, and create three new folders in it, CMSIS (store kernel functions and startup boot files), FWLIB (store library functions), and USER (store user's own functions), as shown in the figure.


     Unzip the downloaded official library, the two marked are mainly used.


    Copy the files in STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\CoreSupport to CMSIS, and then copy all the files in C:STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x to CMSIS. The final CMSIS file is shown in the figure.


        Copy the inc src in STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\STM32F10x_StdPeriph_Driver into the FWLIB folder.


   Copy these files in STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Template into USER,


      So far the preparation is over.


Four, new construction


  Open keil, create a new project temp (there is a project that needs to be closed), and save it in the newly created project.


        After saving, the chip will be selected. I used the STM32F103VE series, so I chose this one.


        After confirming, a window will pop up and turn it off directly (this is to choose to start the boot, etc., we have already downloaded the library, so skip this step). Click the red circled graph, and then change tegart1 to temp. Delete SourceGroup1.


    Add CMSIS, USER, FWLIB, STARTUP in turn, and add the files just copied under the corresponding folder. Note that STARTUP should select startup_stm32f10x_hd.s, startup_stm32f10x_ld.s, startup_stm32f10x_md.s in NewProject\CMSIS\startup\arm. Select all file types. In FWLIB, you only need to add the .c file in src. There is no need to add files in STARTUP in CMSIS. After adding, click OK.


    Then click the magic wand to enter the C/C++ setting interface, enter STM32F10X_HD, USE_STDPERIPH_DRIVER in the define column, and add the header file path in the includepath column.


           includepath content is as follows


        At this point, the project is created. You can click Compile to see if there are any errors.


Five, problems and debugging

  An error was found after compilation, because the main function in the library used directly does not include the #include "stm32_eval.h" header file, so delete it directly. And delete the unused content in other main functions, and include related header files in the main function. The main function of the blank project is shown in the figure.


 In compiling, there are still errors.


It means that there are too many boot files. That is, only one guide can be used in STARTUP. Because of the HD used here, tick off the gray checkmarks of include TargetBulid and Always Bulid in the other two Options for File.


       After the change is completed, there are red bars in front of the other two in STARTUP.

                                           


Compile again, there is still an error.


    It is said that system_stm32f10x_1.c and system_stm32f10x.c are duplicated.

    However, system_stm32f10x_1.c is not found in the check project column . Finally, it was found that there was a duplication in the include file. Click on the box as shown in the figure and find that system_stm32f10x_1.c is included in both CMSIS and USER . Delete system_stm32f10x_1.c in CMSIS . Compile without errors.



    This article is transferred from the cheaper blog, the original link: https://blog.csdn.net/cheapter/article/details/80198168?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-9.control&depth_1-utm_source=distribute.pc_relevant. none-task-blog-OPENSEARCH-9.control .



        

Guess you like

Origin blog.csdn.net/qq_43516928/article/details/110292041