.text
.global _start
_start:
/* 使能GPIOE、GPIOF寄存器 RCC_MP_AHB4ENSETR
* 基地址: 0x50000000 + 偏移地址: 0xA28 = 0x50000A28
* RCC_MP_AHB4ENSETR[4]->1 RCC_MP_AHB4ENSETR[5]->1
*/
LDR R0,=0x50000A28
LDR R1,[R0]
ORR R1,R1,#(0x1<<4)
STR R1,[R0]
LDR R0,=0x50000A28
LDR R1,[R0]
ORR R1,R1,#(0x1<<5)
STR R1,[R0]
/* 设置PE10,PE8,PF10引脚为输出模式
* GPIOF基地址: 0x50007000 + 偏移地址: 0x00 = 0x50007000
* GPIOE基地址: 0x50006000 + 偏移地址: 0x00 = 0x50006000
* PE10: GPIOE_MODER[21:20]->01
* PF10: GPIOF_MODER[21:20]->01
* PE8: GPIOE_MODER[17:16]->01
*/
LDR R0, =0x50007000
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
ORR R1,R1,#(0x1<<20)
STR R1,[R0]
LDR R0, =0x50006000
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
ORR R1,R1,#(0x1<<20)
STR R1,[R0]
LDR R0, =0x50006000
LDR R1,[R0]
BIC R1,R1,#(0x3<<16)
ORR R1,R1,#(0x1<<16)
STR R1,[R0]
/* 设置PE10,PE8,PF10引脚为推挽输出
* GPIOF基地址: 0x50007000 + 偏移地址: 0x04 = 0x50007004
* GPIOE基地址: 0x50006000 + 偏移地址: 0x04 = 0x50006004
* GPIOE_OTYPER[10]->0
* GPIOF_OTYPER[10]->0
* GPIOE_OTYPER[8]->0
*/
LDR R0,=0x50007004
LDR R1,[R0]
BIC R1,R1,#(0x1<<10)
STR R1,[R0]
LDR R0,=0x50006004
LDR R1,[R0]
BIC R1,R1,#(0x1<<10)
STR R1,[R0]
LDR R0,=0x50006004
LDR R1,[R0]
BIC R1,R1,#(0x1<<8)
STR R1,[R0]
/* 设置PE10,PE8,PF10引脚为低速输出
* GPIOF基地址: 0x50007000 + 偏移地址: 0x08 = 0x50007008
* GPIOE基地址: 0x50006000 + 偏移地址: 0x08 = 0x50006008
* GPIOE_OSPEEDR[21:20]->00
* GPIOF_OSPEEDR[21:20]->00
* GPIOE_OSPEEDR[17:16]->00
*/
LDR R0,=0x50007008
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
STR R1,[R0]
LDR R0,=0x50006008
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
STR R1,[R0]
LDR R0,=0x50006008
LDR R1,[R0]
BIC R1,R1,#(0x3<<16)
STR R1,[R0]
/* 设置PE10,PE8,PF10引脚没有上下拉电阻
* GPIOF基地址: 0x50007000 + 偏移地址: 0x0C = 0x5000700C
* GPIOE基地址: 0x50006000 + 偏移地址: 0x0C = 0x5000600C
* GPIOE_PUPDR[21:20]->00
* GPIOF_PUPDR[21:20]->00
* GPIOE_PUPDR[17:16]->00
*/
LDR R0,=0x5000700C
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
STR R1,[R0]
LDR R0,=0x5000600C
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
STR R1,[R0]
LDR R0,=0x5000600C
LDR R1,[R0]
BIC R1,R1,#(0x3<<16)
STR R1,[R0]
/* 设置PE10,PE8,PF10实现流水灯
* GPIOF基地址: 0x50007000 + 偏移地址: 0x14 = 0x50007014
* GPIOE基地址: 0x50006000 + 偏移地址: 0x14 = 0x50006014
* GPIOE_ODR[10]->1
* GPIOF_ODR[10]->1
* GPIOE_ODR[8]->1
*/
loop:
LDR R0,=0X50006014
LDR R1,[R0]
ORR R1,R1,#(0x1<<10)
STR R1,[R0]
BL delay
LDR R0,=0X50006014
LDR R1,[R0]
BIC R1,R1,#(0x1<<10)
STR R1,[R0]
BL delay
LDR R0,=0X50007014
LDR R1,[R0]
ORR R1,R1,#(0x1<<10)
STR R1,[R0]
BL delay
LDR R0,=0X50007014
LDR R1,[R0]
BIC R1,R1,#(0x1<<10)
STR R1,[R0]
BL delay
LDR R0,=0X50006014
LDR R1,[R0]
ORR R1,R1,#(0x1<<8)
STR R1,[R0]
BL delay
LDR R0,=0X50006014
LDR R1,[R0]
BIC R1,R1,#(0x1<<8)
STR R1,[R0]
BL delay
b loop
/* 延时函数 */
delay:
LDR R4,=0X1000000
mm:
CMP R4,#0
SUBNE R4,R4,#1
BNE mm
MOV PC,LR
.end