LED1,LED2,LED3亮灯
.text
.global _start
_start:
/**********LED1点灯--->PE10**************/
/*初始化RCC章节*/
@通过RCC_MP_AHB4ENSETR寄存器,使能GPIOs组控制器 0x500000A28[4] = 1
RCC_INIT:
@ E组和F组一起使能
ldr r0,=0x50000A28
ldr r1,[r0]
orr r1,r1,#(0x3 << 4)
str r1,[r0]
@输出,推挽,速率,上下拉
LED1_INIT:
@通过GPIOx_MODER寄存器设置PE10引脚的模式为输出 0x50006000[21:20] = 01
ldr r0,=0x50006000
ldr r1,[r0]
bic r1,r1,#(0x3 << 20)
orr r1,r1,#(0x1 << 20)
str r1,[r0]
@ PF10
ldr r0,=0x50007000
ldr r1,[r0]
bic r1,r1,#(0x3 << 20)
orr r1,r1,#(0x1 << 20)
str r1,[r0]
@ PE8
ldr r0,=0x50006000
ldr r1,[r0]
bic r1,r1,#(0x3 << 16)
orr r1,r1,#(0x1 << 16)
str r1,[r0]
@通过GPIOx_OTYPER寄存器设置PE10引脚为推挽输出类型 0x50006004[10] = 0
ldr r0,=0x50006004
ldr r1,[r0]
and r1,r1,#(0x0 << 10)
str r1,[r0]
@ PF10
ldr r0,=0x50007004
ldr r1,[r0]
and r1,r1,#(0x0 << 10)
str r1,[r0]
@ PE8
ldr r0,=0x50006004
ldr r1,[r0]
and r1,r1,#(0x0 << 8)
str r1,[r0]
@通过GPIOx_OSPEEDR寄存器设置PE10引脚为低速率输出 0x50006004[21:20] = 00
ldr r0,=0x50006008
ldr r1,[r0]
bic r1,r1,#(0x3 << 20)
str r1,[r0]
@ PF10
ldr r0,=0x50007008
ldr r1,[r0]
bic r1,r1,#(0x3 << 20)
str r1,[r0]
@ PE8
ldr r0,=0x50006008
ldr r1,[r0]
bic r1,r1,#(0x3 << 16)
str r1,[r0]
@通过GPIOx_PUPDR寄存器设置PE10引脚无上下拉 0x5000600C[21:20] = 00
ldr r0,=0x5000600C
ldr r1,[r0]
bic r1,r1,#(0x3 << 20)
str r1,[r0]
@ PF10
ldr r0,=0x5000700C
ldr r1,[r0]
bic r1,r1,#(0x3 << 20)
str r1,[r0]
@ PE8
ldr r0,=0x5000600C
ldr r1,[r0]
bic r1,r1,#(0x3 << 16)
str r1,[r0]
loop:
bl LED1_ON
bl delay_1s
bl LED1_OFF
bl delay_1s
bl LED2_ON
bl delay_1s
bl LED2_OFF
bl delay_1s
bl LED3_ON
bl delay_1s
bl LED3_OFF
bl delay_1s
bl loop
LED1_ON:
@通过GPIOx_ODR寄存器设置PE10引脚输出高电平
ldr r0,=0x50006014
ldr r1,[r0]
orr r1,r1,#(0x1 << 10)
str r1,[r0]
mov pc,lr
LED1_OFF:
@通过GPIOx_ODR寄存器设置PE10引脚输出低电平
ldr r0,=0x50006014
ldr r1,[r0]
and r1,r1,#(0x0 << 10)
str r1,[r0]
mov pc,lr
LED2_ON:
@通过GPIOx_ODR寄存器设置PF10引脚输出高电平
ldr r0,=0x50007014
ldr r1,[r0]
orr r1,r1,#(0x1 << 10)
str r1,[r0]
mov pc,lr
LED2_OFF:
@通过GPIOx_ODR寄存器设置PF10引脚输出低电平
ldr r0,=0x50007014
ldr r1,[r0]
and r1,r1,#(0x0 << 10)
str r1,[r0]
mov pc,lr
LED3_ON:
@通过GPIOx_ODR寄存器设置PE8引脚输出高电平
ldr r0,=0x50006014
ldr r1,[r0]
orr r1,r1,#(0x1 << 8)
str r1,[r0]
mov pc,lr
LED3_OFF:
@通过GPIOx_ODR寄存器设置PE8引脚输出低电平
ldr r0,=0x50006014
ldr r1,[r0]
and r1,r1,#(0x0 << 8)
str r1,[r0]
mov pc,lr
@大概1s的延时函数
delay_1s:
mov r3, #0x10000000
mm:
cmp r3, #0
subne r3, r3, #1
bne mm
mov pc, lr
.end
文章来源:https://www.toymoban.com/news/detail-611557.html
文章来源地址https://www.toymoban.com/news/detail-611557.html
到了这里,关于ARM--LED灯点亮的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!