.global _start
_start:
/**********LED1点亮**************/
@pe10 a28[4] 50006000
LED1_INIT:
@1.通过RCC_AHB4_ENSETR:0x50000A28寄存器设置GPIOE控制器使能 0x50000A28[4] = 1
ldr r0,=0x50000A28
ldr r1,[r0] @将r0寄存器地址中的值,读到r1寄存器中
orr r1,r1,#(0x1 << 4)
@将r1寄存器中的第4位置1
str r1,[r0]
@2.通过GPIOE_MODER:0x50006000寄存器设置PE10引脚为输出模式 0x50006000[21:20]= 01
ldr r0,=0x50006000
ldr r1,[r0]
and r1,r1,#(~(0x3 << 20))
orr r1,r1,#(0x1 << 20)
str r1,[r0]
@3.通过GPIOE_OTYPER:0x50006004寄存器设置PE10引脚为推挽输出模式 0x50006004[10]= 0
ldr r0,=0x50006004
ldr r1,[r0]
and r1,r1,#(~(0x1 << 10))
str r1,[r0]
@4.通过GPIOE_OSPEEDR:0x50006008寄存器设置PE10引脚为低速输出模式0x50006008[21:20]= 00
ldr r0,=0x50006008
ldr r1,[r0]
and r1,r1,#(~(0x3 << 20))
str r1,[r0]
@5.通过GPIOE_PUPDR:0x5000600C寄存器设置PE10引脚为禁止上下拉0x5000600C[21:20]= 00
ldr r0,=0x5000600C
ldr r1,[r0]
and r1,r1,#(~(0x3 << 20))
str r1,[r0]
@pf10 a28[5] 50007000
LED2_INIT:
ldr r0,=0x50000A28
ldr r1,[r0]
orr r1,r1,#(0x1 << 5)
str r1,[r0]
ldr r0,=0x50007000
ldr r1,[r0]
and r1,r1,#(~(0x3 << 20))
orr r1,r1,#(0x1 << 20)
str r1,[r0]
ldr r0,=0x50007004
ldr r1,[r0]
and r1,r1,#(~(0x1 << 10))
str r1,[r0]
ldr r0,=0x50007008
ldr r1,[r0]
and r1,r1,#(~(0x3 << 20))
str r1,[r0]
ldr r0,=0x5000700C
ldr r1,[r0]
and r1,r1,#(~(0x3 << 20))
str r1,[r0]
@pe8 a28 4 50006000
LED3_INIT:
ldr r0,=0x50000A28
ldr r1,[r0]
orr r1,r1,#(0x1 << 4)
str r1,[r0]
ldr r0,=0x50006000
ldr r1,[r0]
and r1,r1,#(~(0x3 << 16))
orr r1,r1,#(0x1 << 16)
str r1,[r0]
ldr r0,=0x50006004
ldr r1,[r0]
and r1,r1,#(~(0x1 << 8))
str r1,[r0]
ldr r0,=0x50006008
ldr r1,[r0]
and r1,r1,#(~(0x3 << 16))
str r1,[r0]
ldr r0,=0x5000600C
ldr r1,[r0]
and 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
b loop
LED1_ON:
@1.通过GPIOE_ODR:0x50006014寄存器设置PE10引脚为输出高电平 0x50006014[10]= 1
ldr r0,=0x50006014
ldr r1,[r0]
orr r1,r1,#(0x1 << 10)
str r1,[r0]
mov pc,lr
LED1_OFF:
@1.通过GPIOE_ODR:0x50006014寄存器设置PE10引脚为输出低电平 0x50006014[10]= 0
ldr r0,=0x50006014
ldr r1,[r0]
and r1,r1,#(~(0x1 << 10))
str r1,[r0]
mov pc,lr
LED2_ON:
ldr r0,=0x50007014
ldr r1,[r0]
orr r1,r1,#(0x1 << 10)
str r1,[r0]
mov pc,lr
LED2_OFF:
ldr r0,=0x50007014
ldr r1,[r0]
and r1,r1,#(~(0x1 << 10))
str r1,[r0]
mov pc,lr
LED3_ON:
ldr r0,=0x50006014
ldr r1,[r0]
orr r1,r1,#(0x1 << 8)
str r1,[r0]
mov pc,lr
LED3_OFF:
ldr r0,=0x50006014
ldr r1,[r0]
and r1,r1,#(~(0x1 << 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
20230419 cortex-a7 点灯试验
最新推荐文章于 2024-11-13 22:18:52 发布