Precautions for using stm32f10x to upgrade Firmware Library 3.1.2

Source: Internet
Author: User

Many Uses3.1.0The Firmware Library of the following versions runs well and is upgraded3.1.2After the Firmware Library is compiled, an error occurs, prompting that the peripheral Firmware Library's function has not been declared. If you encounter this problem, the firmware header is being corrupted, check whether "use_stdperiph_driver, stm32f10x _" is not added to your project settings _HD". And must be added! An error occurs without compilation.

The specific method is to set"Option For targe"=>"C/C ++"Tag =>"Define"Use_stdperiph_driver, stm32f10x _HD.

Note:The stm32f10x_hd above should be defined according to the startup code you selected. If you use startup_stm32f10x_cl.s, you should write stm32f10x_cl here. The other startup code writing formats are the same.

-- Upgrade from _ stm32f10xxx Firmware Library _ v2.0.3 _ to _ stm32f10xxx standard peripheral library _ v3.0.0.

1. let's start with this question. We all know which peripherals we choose to use are to change the-48 lines of the stm32f10x_conf.h file copied from the official template, include the peripheral header file that we want to use and comment out the peripheral header file that we don't need. But do you find that we didn't include the file stm32f10x_conf.h in the main program file of the user. How can we modify this file to access the main program file? There is only one answer, which is included in stm32f10x. h. In this file, # include "stm32f10x. H ", so it should be stm32f10x. h. This file contains stm32f10x_conf.h, Which is indirectly included in the main program file of the user. (In fact, let's take a look at the file structure of the Firmware Library and we can see that this is indeed the case. We guess it is right. Refer to 1.)

Figure 1. Architecture of stm32f10xxx standard peripheral Library


2. With the above understanding, we can search for "stm32f10x_conf.h" in stm32f10x. H. We can see the following code in line 7811-7813:
# Ifdef use_stdperiph_driver
# Include "stm32f10x_conf.h"
# Endif
Do you see the problem?This condition compilation means:If the use_stdperiph_driver tag is defined, it contains stm32f10x_conf.h.. Needless to say, we want to use the Firmware Library, so we should predefine the use_stdperiph_driver mark. Keil provides a way to pre-define the mark before compilation, that is, the above mentioned setting in the project"Option
For targe
"=>"C/C ++"Tag =>"Define"Use_stdperiph_driver. See Figure 2:

Figure 2. Keil Development Environment (C/C ++ pre-setting window)


3. You must have seen that I have added another mark, stm32f10x_hd, to the pre-set area above. If it is not defined, it can be compiled. What is the purpose of this mark? If you do not know what to do? Search for "stm32f10x_hd" in the stm32f10x. h file, and you will find lines 47-52:
# If! Defined (stm32f10x_ld )&&! Defined (stm32f10x_md )&&! Defined (stm32f10x_hd )&&! Defined (stm32f10x_cl)
/* # Define stm32f10x_ld *//*! <Stm32f10x_ld: stm32 low density devices */
/* # Define stm32f10x_md *//*! <Stm32f10x_md: stm32 medium density devices */
/* # Define stm32f10x_hd *//*! <Stm32f10x_hd: stm32 high density devices */
# Define stm32f10x_cl /*! <Stm32f10x_cl: stm32 connectivity line devices */
# Endif
You should have understood,Compile this condition:When no tag is defined, a stm32f10x_cl tag is automatically defined.. This explains why we can compile without defining the stm32f10x_hd mark, but it is obvious that it is not what we want by default. Which of the following statements is correct? This is determined by our CPU. The CPU we use is running Rx/VX/ZX, which is a high-density chip. Therefore, the startup code we choose is the startup_stm32f10x_hd.s file, the Mark defined here should be stm32f10x_hd.
In fact, you can search for "stm32f10x_hd" and find many conditional compilations that are determined by him. There are too many related content. I will not go into details here. You will find it by yourself.

4.Summary: compared with the Firmware Library earlier than 3.1.0, this Firmware Library is more reasonable. The compilation of this condition actually determines the form of development by the customer. If you use the st Firmware Library, precompile these labels. If you use the Register operation method to write programs without using the Firmware Library, you can skip these two conditions to compile the tag, so that the program is lightweight and the compilation speed will be faster.


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: 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.