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、思维导图
文章来源:https://www.toymoban.com/news/detail-603051.html
文章来源地址https://www.toymoban.com/news/detail-603051.html
到了这里,关于ARM day4的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!