1.汇编代码
.text
.global _start
_start:
//RCC初始化
RCC_INIT:
//设置GPIOE组使能
ldr r0,=0x50000A28
ldr r1,[r0]
orr r1,r1,#(0x1<<4)
str r1,[r0]
//设置GPIOF组使能
ldr r0,=0x50000A28
ldr r1,[r0]
orr r1,r1,#(0x1<<5)
str r1,[r0]
//LED1灯初始化
LED1_INIT:
//设置模式为输出模式
@ 0x50006000[21:20]=01
ldr r0,=0x50006000
ldr r1,[r0]
orr r1,r1,#(0x1<<20)
bic r1,r1,#(0x1<<21)
str r1,[r0]
//设置输出类型为推挽输出
@ 0x50006004[10]=0
ldr r0,=0x50006004
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
//设置输出速率为低速
@ 0x50006008[21:20]=00
ldr r0,=0x50006008
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
str r1,[r0]
//设置上下拉电阻为不上下拉
@ 0x5000600C[21:20]=00
ldr r0,=0x5000600C
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
str r1,[r0]
//LED2灯初始化
LED2_INIT:
//设置模式为输出模式
@ 0x50007000[21:20]=01
ldr r0,=0x50007000
ldr r1,[r0]
orr r1,r1,#(0x1<<20)
bic r1,r1,#(0x1<<21)
str r1,[r0]
//设置输出类型为推挽输出
@ 0x50007004[10]=0
ldr r0,=0x50007004
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
//设置输出速率为低速
@ 0x50007008[21:20]=00
ldr r0,=0x50007008
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
str r1,[r0]
//设置上下拉电阻为不上下拉
@ 0x5000700C[21:20]=00
ldr r0,=0x5000700C
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
str r1,[r0]
//LED3灯初始化
LED3_INIT:
//设置模式为输出模式
@ 0x50006000[17:16]=01
ldr r0,=0x50006000
ldr r1,[r0]
orr r1,r1,#(0x1<<16)
bic r1,r1,#(0x1<<17)
str r1,[r0]
//设置输出类型为推挽输出
@ 0x50006004[8]=0
ldr r0,=0x50006004
ldr r1,[r0]
bic r1,r1,#(0x1<<8)
str r1,[r0]
//设置输出速率为低速
@ 0x50006008[17:16]=00
ldr r0,=0x50006008
ldr r1,[r0]
bic r1,r1,#(0x3<<16)
str r1,[r0]
//设置上下拉电阻为不上下拉
@ 0x5000600C[17:16]=00
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
b loop
//LED1灯点亮
LED1_ON:
@ 0x50006014[10]=1
ldr r0,=0x50006014
ldr r1,[r0]
orr r1,r1,#(0x1<<10)
str r1,[r0]
mov pc,lr
//LED1灯熄灭
LED1_OFF:
ldr r0,=0x50006014
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
mov pc,lr
//LED2灯点亮
LED2_ON:
@ 0x50007014[10]=1
ldr r0,=0x50007014
ldr r1,[r0]
orr r1,r1,#(0x1<<10)
str r1,[r0]
mov pc,lr
//LED2灯熄灭
LED2_OFF:
ldr r0,=0x50007014
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
mov pc,lr
//LED3灯点亮
LED3_ON:
@ 0x50006014[8]=1
ldr r0,=0x50006014
ldr r1,[r0]
orr r1,r1,#(0x1<<8)
str r1,[r0]
mov pc,lr
//LED3灯熄灭
LED3_OFF:
ldr r0,=0x50006014
ldr r1,[r0]
bic 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
实现现象
IMG_1044
2.思维导图