ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

【STM32第一个工程】

【STM32第一个工程】 STM32 第一个工程一、找到STM32的库1. 了解库的组成库文件1.1 内核文件内核启动文件1.2 外设文件.c文件.h文件2. 找到需要的文件2.1内核文件2.2启动文件2.3外设文件 .c .h 如果你不确定就全部拷贝二、新建工程1. 新建4个文件夹2. 往文件里面拷贝对应的文件COREFWLIBUSER3.将工程建立在指定文件夹里面将工程建立在USER 里面4. 配置工程参数1. 将4个文件夹的内容添加到工程中1.添加.c文件COREFWLIBUSER2.添加.h文件成功添加完.h文件的工程配置添加宏定义宏定义配置完毕5.编译软件版本不要太高5.1基本编译操作工程成功了 撒花了5.2 视频中编译出现的错误问题修改编译器版本修改编译器为56. 下载下载标志三 、工程main.c 工程解释//头文件#includestm32f10x.h/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*///全局变量GPIO_InitTypeDef GPIO_InitStructure;/* Private function prototypes -----------------------------------------------*//* Private functions ---------------------------------------------------------*///主函数intmain(void){//开启外设时钟GPIODRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);//配置引脚 GPIOD0 2 为复用推挽输出/* Configure PD0 and PD2 in output pushpull mode */GPIO_InitStructure.GPIO_PinGPIO_Pin_0|GPIO_Pin_2;GPIO_InitStructure.GPIO_SpeedGPIO_Speed_50MHz;GPIO_InitStructure.GPIO_ModeGPIO_Mode_Out_PP;GPIO_Init(GPIOD,GPIO_InitStructure);while(1){//寄存器的方式 驱动引脚输出高低电平/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;/* Set PD0 and PD2 */GPIOD-BSRR0x00000005;/* Reset PD0 and PD2 */GPIOD-BRR0x00000005;}}四、手把手教学视频bilbilhttps://www.bilibili.com/video/BV1ZCHrzSEgP/csdn20250912_164004-第一个工程视频错误看 5.2修改
返回列表