微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于正点原子建立STM32F10x库函数版本的工程自己例程

基于正点原子建立STM32F10x库函数版本的工程自己例程

时间:11-28 来源:互联网 点击:
步骤:

1、建立工程文件夹test

2、按下列复制文件夹到test工程文件夹:

1)复制例程的下列4个文件夹到工程目录:

HARDWARE

SYSTEM

CORE

STM32F10X_FWLIB

2)在工程目录建立一个user文件夹,并复制例程文件下列文件:

复制2文件:stm32f10x_it.c,stm32f10x_it.h

复制2文件:system_stm32f10x.c,system_stm32f10x.h

3、在user下新建工程test.uvproj

4、在user下新建代码文件test.c,内容如下:

#include "led.h"

#include "delay.h"

#include "sys.h“

#include"stm32f10x_gpio.h"

int main(void)

{

SystemInit();//系统时钟初始化为72MSYSCLK_FREQ_72MHz

delay_init(72);//延时函数初始化

NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级

LED_Init();//LED端口初始化

while(1)

{

GPIO_ResetBits(GPIOA,GPIO_Pin_8);//LED0=0;

GPIO_SetBits(GPIOD,GPIO_Pin_2);//LED1=1;

delay_ms(300);

GPIO_SetBits(GPIOA,GPIO_Pin_8);//也可以使用 LED0=1;

GPIO_ResetBits(GPIOD,GPIO_Pin_2) ; //也可以使用 LED1=0;

delay_ms(300);

}

}

5、向工程添加文件及分组管理工程文件

建立工程下的组(与文件夹对应),分别添加文件到工程组。

6、工程设置

nDevice选:TSM32F103RB

Output输入: test

C/C++页面:

Processor Symbols Define:STM32F10X_MD,USE_STDPERIPH_DRIVER

并添加:Include paths



7、build建立目标代码

build过程中错误修改:

问题及修改:

1)..SYSTEMdelaydelay.c(27): error:#20: identifier "SysTick_CLKSource_HCLK_Div8" is undefined

解决方法:在delay.c中添加“#include"misc.h"”

2)..SYSTEMsyssys.c(18): error:#20: identifier "NVIC_PriorityGroup_2" is undefined

解决方法:在sys.c中添加“#include"misc.h"”

3). ..SYSTEMusartusart.c(75): error:#20: identifier "GPIO_InitTypeDef" is undefined

解决方法:在usart.c中添加“#include”stm32f10x_gpio.h””

4)..SYSTEMusartusart.c(77): error:#20: identifier "USART_InitTypeDef" is undefined

解决方法:在usart.c中添加“#include"stm32f10x_usart.h"”

5)..SYSTEMusartusart.c(80): error:#20: identifier "NVIC_InitTypeDef" is undefined

解决方法:在usart.c中添加“#include"misc.h"”

6)..SYSTEMusartusart.c(82): warning:#223-D: function "RCC_APB2PeriphClockCmd" declared implicitly

解决方法:在usart.c中添加“#include"stm32f10x_rcc.h"”

7)..HARDWARELEDled.c(22): error:#20: identifier "GPIO_InitTypeDef" is undefined

解决方法:在led.c中添加“#include"stm32f10x_gpio.h"”

8)..HARDWARELEDled.c(25): error:#20: identifier "RCC_APB2Periph_GPIOA" is undefined

解决方法:在led.c中添加“#include"stm32f10x_rcc.h"”

8、build target结果



Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top