用车
assert_param(STM32跑马灯——库函数(从0开始))

1:基础知识准备工作:

1:GPIO

每组IO有16个IO口,这16个IO口通过先七个寄存器来进行控制

头文件:stm32f10x_gpio.h

源文件:stm32f10x_gpio.c

(可以通过keil 自带的Manage run-Time Environment工具添加)

  • 本次使用到的函数:
//初始化函数:void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);//读取输入电平函数:uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);//读取输出电平函数:uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);//设置输出电平函数:void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);


2:环境搭建:

1:创建工程

a:选择型号:

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">


b:这里选择我们运行程序的三个相关的。

1:内核接口,所有函数最终调用的是他,这里也是stm32 光放提供的

2:第二个GPIO相关的,也是我们即将点亮LED使用的用户接口

3:启动相关的程序,怎么从汇编代码调用到C语言。这里不懂得可以看《30天自制操作系统》

c:工程建立好了如下:

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

d:设置烧录工具

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

e:设置烧录方式

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

f:到这里简单的工程就创建好了

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

编译的时候可能遇到如下错误

错误2:

D:\soft\keil5\packs\Keil\STM32F1xx_DFP\1.1.0\Device\Include\stm32f10x.h(8302): error: #5: cannot open source input file "stm32f10x_conf.h": No such file or directory

#include "stm32f10x_conf.h"

修改方法如下图:

STM32跑马灯——库函数(从0开始)nerror="javascript:errorimg.call(this);">

3:开始真正的流水灯程序编写


顶一下()     踩一下()

热门推荐

发表评论
0评