.text
.global _start
_start:
/**********LED1点灯**************/
RCC_INIT:
LDR R0,=0X50000A28
LDR R1,[R0]
orr R1,R1,#(0x1<<4)
orr R1,R1,#(0X1<<5)
STR R1,[R0]
LED1_INIT:
/**/
LDR R0,=0X50006000
LDR R1,[R0]
and R1,R1,#(~(0X3<<20))
orr R1,R1,#(0x1<<20)
STR R1,[R0]
/**/
LDR R0,=0X50006004
LDR R1,[R0]
and R1,R1,#(~(0X1<<10))
STR R1,[R0]
/**/
LDR R0,=0X50006008
LDR R1,[R0]
and R1,R1,#(~(0X11<<20))
STR R1,[R0]
/**/
LDR R0,=0X5000600C
LDR R1,[R0]
and R1,R1,#(~(0X11<<20))
STR R1,[R0]
LED2_INIT:
/**/
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,#(~(0X11<<20))
STR R1,[R0]
/**/
LDR R0,=0X5000700C
LDR R1,[R0]
and R1,R1,#(~(0X11<<20))
STR R1,[R0]
LED3_INIT:
/**/
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,#(~(0X11<<16))
STR R1,[R0]
/**/
LDR R0,=0X5000600C
LDR R1,[R0]
and R1,R1,#(~(0X11<<16))
STR R1,[R0]
main:
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 main
LED1_ON:
LDR R0,=0X50006014
LDR R1,[R0]
orr R1,R1,#(0X1<<10)
STR R1,[R0]
mov pc, lr
LED1_OFF:
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
2.文章来源:https://www.toymoban.com/news/detail-601049.html
文章来源地址https://www.toymoban.com/news/detail-601049.html
到了这里,关于arm点灯的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!