要使程序编译成功,还需在 “Options for target ‘marquee’”弹出框中设置 “C/C++”相应配置项
①设置“Preprocessor Symbols”,如下图
②设置 “Include Paths”,即设置相应库函数的目录,如下图 USE_STDPERIPH_DRIVER :表示是否在应用中启用外设驱动。我们使用标准外设库是为了方便控制外设,添加这个定义,以启用外设驱动。( to use or not the peripheral’s drivers in application code (i.e. code will be based on direct access to peripheral’s registers rather than drivers API) , this option is controlled by the #define USE_STDPERIPH_DRIVER)
STM32F10X_HD:STM32F10X系列每种系列都有所区别,例如sram或者flash或者外设数量不一样,所以stm32标准外设库必须根据你使用的处理器来做相应的预处理。
在stm32f10x.h可以看到相应的宏定义,如下:
#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) /* #define STM32F10X_LD *//*!< STM32F10X_LD: STM32 Low density devices *//* #define STM32F10X_LD_VL *//*!< STM32F10X_LD_VL: STM32 Low density Value Line devices *//* #define STM32F10X_MD *//*!< STM32F10X_MD: STM32 Medium density devices *//* #define STM32F10X_MD_VL *//*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices *//* #define STM32F10X_HD *//*!< STM32F10X_HD: STM32 High density devices *//* #define STM32F10X_HD_VL *//*!< STM32F10X_HD_VL: STM32 High density value line devices *//* #define STM32F10X_XL *//*!< STM32F10X_XL: STM32 XL-density devices *//* #define STM32F10X_CL *//*!< STM32F10X_CL: STM32 Connectivity line devices */#endif#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)#error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"#endif
1-2)采用ST-Link下载程序
使用ST-Link方式下载程序我们可以使用debug功能在线调试代码,建议开发阶段使用这种方式。
ST-Link方式下载程序设置方式如下图: