mini2440(4) 我的第一个ARM汇编程序---LED灯裸机硬件控制程序

原理图及相关寄存器,请参考:mini2440(2) LED灯裸机硬件控制程序

这个裸机控制LED灯的程序通过JLink和AXD在mini2440开发板上运行,产生的效果是mini2440上的4个LED不停的循环亮、灭,程序的汇编语言代码源码:


AWTCON EQU 0x53000000
VWTCON EQU (~(1<<5))

AINTMSK EQU 0x4A000008
VINTMSK EQU 0xFFFFFFFF

AINTSUBMSK EQU 0x4A00001C
VINTSUBMSK EQU 0x7FF

AREA Init, CODE, READONLY
ENTRY

LDR R0, =AWTCON
LDR R1, =VWTCON
STR R1, [R0]

LDR R0, =AINTMSK
LDR R1, =VINTMSK
STR R1, [R0]

LDR R0, =AINTSUBMSK
LDR R1, =VINTSUBMSK
STR R1, [R0]

LED_FLASH
BL LED_ON

BL LED_DELAY

BL LED_OFF

LDR R0, =LED_FLASH
MOV PC, R0

LOOP B LOOP

AGPBCON EQU 0x56000010
VGPBCON EQU (1<<10|1<<12|1<<14|1<<16)
AGPBDAT EQU 0x56000014
VLEDON EQU (~(1<<5|1<<6|1<<7|1<<8))
VLEDOFF EQU ((1<<5|1<<6|1<<7|1<<8))

LED_ON
LDR R0, =AGPBCON
LDR R1, =VGPBCON
STR R1, [R0]

LDR R0, =AGPBDAT
LDR R1, =VLEDON
STR R1, [R0]

MOV PC, R14

LED_OFF
LDR R0, =AGPBCON
LDR R1, =VGPBCON
STR R1, [R0]

LDR R0, =AGPBDAT
LDR R1, =VLEDOFF
STR R1, [R0]

MOV PC, R14

VLEDDELAY EQU 0x0000FFFF
LED_DELAY
LDR R0, =VLEDDELAY
MOV R1, #0x0
LED_SUB
SUB R0, R0, #0x1
CMP R1, R0

MOVEQ PC, R14

LDR R2, =LED_SUB
MOV PC, R2

END


目前LED_DELAY代码段使用JLink调试似乎有问题,不知道是因为使用JLink的问题呢还是程序代码本身的问题?后面将程序烧写到Flash中再行测试,期待结果!

你可能感兴趣的:(mini2440(4) 我的第一个ARM汇编程序---LED灯裸机硬件控制程序)