1、实现LED1/LED2/LED3三盏灯循环点亮熄灭(统一上传链接,代码截图、实验现象图片)
.text
.global _start
_start:
/**********LED1点灯**************/
/*初始化RCC章节*/
RCC_INIT:
@通过RCC_MP_AHB4ENSETR寄存器,使能GPIOE组控制器
LDR R0,=0X50000A28
LDR R1,[R0]
ORR R1,R1,#(0X1 << 4)
STR R1,[R0]
LDR R2,=0X50000A28
LDR R3,[R2]
ORR R3,R3,#(0X1 << 5)
STR R3,[R2]
LED1_INIT:
@通过GPIOE_MODER寄存器设置PE10引脚为输出模式
LDR R0,=0X50006000
LDR R1,[R0]
ORR R1,R1,#(0X1 << 20)
BIC R1,R1,#(0X1 << 21)
STR R1,[R0]
LDR R2,=0X50007000
LDR R3,[R2]
ORR R3,R3,#(0X1 << 20)
BIC R3,R3,#(0X1 << 21)
STR R3,[R2]
LDR R0,=0X50006000
LDR R1,[R0]
ORR R1,R1,#(0X1 << 16)
BIC R1,R1,#(0X1 << 17)
STR R1,[R0]
@通过GPIOE_OTYPER寄存器设置PE10引脚为推挽输出类型
LDR R0,=0X50006004
LDR R1,[R0]
BIC R1,R1,#(0X1 << 10)
STR R1,[R0]
LDR R2,=0X50007004
LDR R3,[R2]
BIC R3,R3,#(0X1 << 10)
STR R3,[R2]
LDR R0,=0X50006004
LDR R1,[R0]
BIC R1,R1,#(0X1 << 8)
STR R1,[R0]
@通过GPIOE_OSPEEDR寄存器设置PE10引脚为低速输出
LDR R0,=0X50006008
LDR R1,[R0]
BIC R1,R1,#(0X1 << 20)
BIC R1,R1,#(0X1 << 21)
STR R1,[R0]
LDR R2,=0X50007008
LDR R3,[R2]
BIC R3,R3,#(0X1 << 20)
BIC R3,R3,#(0X1 << 21)
STR R3,[R2]
LDR R0,=0X50006008
LDR R1,[R0]
BIC R1,R1,#(0X1 << 16)
BIC R1,R1,#(0X1 << 17)
STR R1,[R0]
@通过GPIOE_PUPDR寄存器设置PE10引脚禁止上下拉电阻
LDR R0,=0X5000600C
LDR R1,[R0]
BIC R1,R1,#(0X1 << 20)
BIC R1,R1,#(0X1 << 21)
STR R1,[R0]
LDR R2,=0X5000700C
LDR R3,[R2]
BIC R3,R3,#(0X1 << 20)
BIC R3,R3,#(0X1 << 21)
STR R3,[R2]
LDR R0,=0X5000600C
LDR R1,[R0]
BIC R1,R1,#(0X1 << 16)
BIC R1,R1,#(0X1 << 17)
STR R1,[R0]
LED_ON:
@通过GPIOE_ODR寄存器设置PE10引脚输出高电平
LDR R0,=0X50006014
LDR R1,[R0]
ORR R1,R1,#(0X1 << 10)
STR R1,[R0]
bl delay_1s
LDR R2,=0X50007014
LDR R3,[R2]
ORR R3,R3,#(0X1 << 10)
STR R3,[R2]
bl delay_1s
LDR R0,=0X50006014
LDR R1,[R0]
ORR R1,R1,#(0X1 << 8)
STR R1,[R0]
bl delay_1s
LED1_OFF:
@通过GPIOE_ODR寄存器设置PE10引脚输出低电平
LDR R0,=0X50006014
LDR R1,[R0]
BIC R1,R1,#(0X1 << 10)
STR R1,[R0]
bl delay_1s
LDR R2,=0X50007014
LDR R3,[R2]
BIC R3,R3,#(0X1 << 10)
STR R3,[R2]
bl delay_1s
LDR R0,=0X50006014
LDR R1,[R0]
BIC R1,R1,#(0X1 << 8)
STR R1,[R0]
bl delay_1s
b LED_ON
@ 大概1s的延时函数
delay_1s:
mov r3, #0x10000000
mm:
cmp r3, #0
subne r3, r3, #1
bne mm
mov pc, lr
.end
led
2、思维导图