After creating a new STM32 project in uVision, you need to copy the standard peripheral driver from the STM32 standard library to your own project directory. At this time, you need to type these two global macro definitions in the define text box under the project settings – > C / C + + tab.

STM32F40_ 41xxx,USE_ STDPERIPH_ DRIVER

USE_ STDPERIPH_ DRIVER

This shows that you are using the standard peripheral driver and have your own peripheral configuration file, stm32f10x_ Conf.h, see lines 12026-12017 in stm32f4xx. H for details. About stm32f4xx_ conf.h

Reasons for creating two macros for STM32 project global declaration

The contents of the file are selectively #include “stm32f4xx_conf.h”, which only compiles the required peripheral files and reduces the volume of hex files. If you don’t use this macro, or if you don’t have stm32f10x_ Conf.h file, there will be a lot of inexplicable errors during compilation, because stm32f40x is also included in MDK_ XXXX. H file, so that the compiler uses the. H file in MDK, and the versions of. C file and. H file do not match.

Note that if the library file is wrong, there must be a problem with your project configuration.

Use Standard Peripheral Driver

  when using STM32 firmware library to build a project in keil MDK environment, you may encounter the problem of compilation failure. The following warning or error message appears:

warning:#223-D:function”assert_param”declaredimplicitly; assert_ param(IS_GPIO_ALL_PERIPH(GPIOx));

At this time, we need to add stm32f40 in the C / C + + tab of “targetoptions” in the setting panel_ 41xxx,USE_ STDPERIPH_ DRIVER。 Only in this way can the compilation pass smoothly.

We know why. Let’s do it together. As we know, the execution of the program starts from the main. C file, which must contain the header file stm32f4xx. H. Open stm32f4xx. H and find use_ STDPERIPH_ Driver, found on lines 12026-12017

#ifdef USE_ STDPERIPH_ DRIVER #include “stm32f4xx_conf.h”

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *