stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01

stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01 目录

    • 分组
    • 添加main.c
    • debug问题
      • 设置
    • 正式debug

keil 5
STM32F103ZE

需要启动文件

分组

不细谈

不分也可以

添加main.c

//1.根据文档 知道 GPIOF_BASE IS 0x40011C00
//2.查看 寄存器偏移地址 得到每个寄存器地址
//3.得到地址 定义指针 指向 地址 进行操作
#define GPIOF_BASE  *(unsigned int *)0x40011C00
#define GPIOF_CRL   *(unsigned int *)0x40011C00
#define GPIOF_CRH   *(unsigned int *)0x40011C04
#define GPIOF_IDR  	*(unsigned int *)0x40011C08
#define GPIOF_ODR   *(unsigned int *)0x40011C0C
#define GPIOF_BSSR  *(unsigned int *)0x40011C10
#define GPIOF_BRR   *(unsigned int *)0x40011C14
#define GPIOF_LCKR  *(unsigned int *)0x40011C18


int main(void){
	
	// set input mode and cnf
	// docment:input cnf is 00 and 11 mode is 00 00
	// so cnf and mode is 0000 0011 = 0x3;
	GPIOF_CRL =0x03;
	
	//set ouutput mode and cnf
	//docment:output cnf is 00 and 00 mode is  1 and 1
	//so cnf and mode is  0100 0000;
	
	// normal  50M output
	
	GPIOF_CRH =0x04;
	
	// while to debug
	while(1){
		if((GPIOF_IDR & 0x0100) == 0x0100){
			GPIOF_ODR = 0x01;
		}else{
			GPIOF_ODR = 0x00;
		}
	}
	//return (1);
}


debug问题

设置

魔术棒 > debug
stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01_第1张图片

使用仿真设置
stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01_第2张图片

正式debug

stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01_第3张图片
2.stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01_第4张图片
3.
stm32 GPIOF设置 mode and cnf 第八位输入 01 第零位 输出 01_第5张图片

你可能感兴趣的:(硬件,stm32,单片机,arm)