畅通无阻,快速搭建STM32F103C8T6开发环境
目录
一、硬件包下载
二、标准库下载
三、库导入
四、编译
STM32使用keil5 MDK-ARM开发。 基于stm32f103c8t6芯片的开发板网上主流的一款开发板,资料多,开源项目也多,便于入门。stm32f103c8t6开发板拥有着主流增强型ARM Cortex-M3 MCU,具有64 KB Flash、72 MHz CPU、电机控制、USB和CAN等。这里没有给keil和protues软件资源,因为知识产权保护,大家可以去网上找。
一、硬件包下载
官网查得该系列属于STM32F1系列
非官网下载渠道,但下载速度快(不是最新的库,已经够用了)
进入网页后点击上图圈出的就可以下载了,下载完成以后,双击硬件包,一直点next就行,安装完成,点finish。
二、标准库下载
官网下载渠道,下载速度慢(标准库到3.6就一直没更新了)
进入网页后,点击Get latest 即可开始下载,完成后解压到自己便于查找的位置。
三、库导入
在自己方便查找的地方新建一个demo文件夹。
再新建project放到demo文件夹下。
然后选择CPU stm32f103c8。
点击图中蓝色圈出的地方,添加组cmsis,startup,std,users。
将下载的标准库里面的文件批量添加到各个组里(可先将标准库文件下的二级文件复制到demo文件夹下,再添加,以免后续编译时出现错误,比如编译器找不到头文件等),添加完毕后点击OK。
然后点击魔术棒,点击C/C++栏,IncludePaths添加所有组里.c和.s文件对应的.h文件的文件夹(这里涉及到编译的原理,暂时不用深究)。
接着再Define框内写上USE_STDPERIPH_DRIVER。
最后新建main.c和stm32f10x_conf.h文件到user组里。
#include "Device/Include/stm32f10x.h" // Device header
int main()
{
while(1);
}
/**
******************************************************************************
* @file CortexM3/MPU/stm32f10x_conf.h
* @author MCD Application Team
* @version V3.6.0
* @date 20-September-2021
* @brief Library configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2011 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F10x_CONF_H
#define __STM32F10x_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
#include "stm32f10x_adc.h"
#include "stm32f10x_bkp.h"
#include "stm32f10x_can.h"
#include "stm32f10x_cec.h"
#include "stm32f10x_crc.h"
#include "stm32f10x_dac.h"
#include "stm32f10x_dbgmcu.h"
#include "stm32f10x_dma.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_fsmc.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_i2c.h"
#include "stm32f10x_iwdg.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_rtc.h"
#include "stm32f10x_sdio.h"
#include "stm32f10x_spi.h"
#include "stm32f10x_tim.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function which reports
* the name of the source file and the source line number of the call
* that failed. If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32F10x_CONF_H */
/**
******************************************************************************
* @file CortexM3/MPU/stm32f10x_conf.h
* @author MCD Application Team
* @version V3.6.0
* @date 20-September-2021
* @brief Library configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2011 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F10x_CONF_H
#define __STM32F10x_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
#include "stm32f10x_adc.h"
#include "stm32f10x_bkp.h"
#include "stm32f10x_can.h"
#include "stm32f10x_cec.h"
#include "stm32f10x_crc.h"
#include "stm32f10x_dac.h"
#include "stm32f10x_dbgmcu.h"
#include "stm32f10x_dma.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_fsmc.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_i2c.h"
#include "stm32f10x_iwdg.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_rtc.h"
#include "stm32f10x_sdio.h"
#include "stm32f10x_spi.h"
#include "stm32f10x_tim.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function which reports
* the name of the source file and the source line number of the call
* that failed. If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32F10x_CONF_H */
四、编译
勾选Create HEX File并设定晶振频率。
点击编译。
没出现任何报错,之后会慢慢的更新一些实用的嵌入式项目,感谢各位的支持(*^_^*)!
作者:sword devil900