什么也不说了,直接上代码,这一节我们要用到ARM汇编,具体的ARM指令我们将在代码中讲解
.global
_start:
#ldr将0xE0200280这个地址加载入寄存器R1,R1寄存器内容则为GPJCON2[31:0],并且设置GPJ2CON_0,GPJ2CON_1,GPJ2CON_2,GPJ2CON_3为输出,最后将内存中的数据加载进入寄存器中
ldr r1, =0xE0200280
ldr r0, =0x00001111
str r0, [r1]
mov r2, #0x1000
#将GPJ2DAT[7:0]寄存器设置为0x0,即全部输出为低电平,来点亮LED灯
led_blink:
ldr r1, =0xE0200284
mov r0, #0
str r0, [r1]
bl delay
#将GPJ2DAT[7:0]寄存器设置为0xf,即全部输出为高电平,来熄灭LED灯
ldr r1, =0xE0200284
mov r0, #0xf
str r0, [r1]
bl delay
sub r2, r2, #1
cmp r2, #0
bne led_blink
halt:
b halt
delay:
mov r0, #0x100000
delay_loop:
cmp r0, #0
sub r0, r0, #1
bne delay_loop
mov pc, lr