- 论坛徽章:
- 0
|
回复 #7 conke 的帖子
代码修改了一下,增加了打印hello world功能,请指正。
**************************************
.text
.global Start
Start:
b Reset
b Reset
b Reset
b Reset
b Reset
.word End - Start
b Reset
b Reset
Reset:
@disable watchdog
ldr r0, =AT91SAM926X_PA_WDTC
mov r1, #(0x1 << 15)
str r1, [r0, #WDTC_WDMR]
@InitClock
ldr r0, =AT91SAM926X_PA_PMC
ldr r1, =(1 << 29 | MULA << 16 | OUTA << 14 | 0x3f << 8 | DIVA)
str r1, [r0, #PMC_PLLAR]
loop1:
ldr r1, [r0, #PMC_SR]
tst r1, #2
beq loop1
ldr r1, =(1 << 8 | 2)
str r1, [r0, #PMC_MCKR]
loop2:
ldr r1, [r0, #PMC_SR]
tst r1, #8
beq loop2
@InitUart
ldr r0, =AT91SAM926X_PA_PIOC
@pc31 and pc30
mov r1, #0xC0000000
str r1, [r0, #PIO_PDR]
str r1, [r0, #PIO_ASR]
ldr r0, =AT91SAM926X_PA_DBGU
mvn r1, #0
str r1, [r0, #US_IDR]
mov r1, #(0x4 << 9)
str r1, [r0, #US_MR]
mov r1, #DBUG_BAUD_RATE_CD
str r1, [r0, #US_BRGR]
@print "Hello world"
ldr r2, L1
loop3:
ldrb r1, [r2]
cmp r1, #0
beq OnLed
loop4:
ldr r3, [r0, #US_CSR]
and r3, r3, #0x2
tst r3, #0x2
beq loop4
strb r1, [r0, #US_THR]
add r2, r2, #1
b loop3
@get the chip's id
ldr r1, [r0, #US_FIDI]
and r1, r1, #0xE0
cmp r1, #0xA0
bne loop5
@OnLed
ldr r0, =AT91SAM926X_PA_PIOC
@ ds1 & pc29
mov r1, #0x20000000
str r1, [r0,#PIO_PER]
str r1, [r0,#PIO_OER]
str r1, [r0,#PIO_CODR]
loop5:
b loop5
L1:
.word String
.data
.align 2
String:
.asciz "Hello world!\n" |
|