小弟,初学ARM11,今天将韦东山的PLL倍频的启动代码修改过后,发现没有错误,但是下到板子上不能运行,不知道为什么,求各位大神帮忙看看代码,感激不尽。以下是启动代码,我的C函数是让4个LED闪烁。若是将以下代码中的时钟部分去掉,则可以正常运行
IMPORT main
OTHERS EQU 0x7e00f900
ARM_RATIO EQU 0 ;ARMCLK = DOUTAPLL / (ARM_RATIO + 1)
HCLKX2_RATIO EQU 1 ;HCLKX2 = HCLKX2IN / (HCLKX2_RATIO + 1)
HCLK_RATIO EQU 1 ;HCLK = HCLKX2 / (HCLK_RATIO + 1)
PCLK_RATIO EQU 3 ; PCLK = HCLKX2 / (PCLK_RATIO + 1)
MPLL_RATIO EQU 0 ;DOUTMPLL = MOUTMPLL / (MPLL_RATIO + 1)
APLL_CON_VAL EQU ((1<<31) | (266 << 16) | (3 << 8) | (1))
MPLL_CON_VAL EQU ((1<<31) | (266 << 16) | (3 << 8) | (1))
AREA Example,CODE,READONLY
PRESERVE8
EXPORT Example
global start
start
ldr r0,=0x70000000
orr r0,r0,#0x13
mcr p15,0,r0,c15,c2,4
ldr r0,=0x7E004000
mov r1,#0
str r1,[r0]
;1.设置LOCK_TIME
ldr r0,=0x7E00F000 ; APLL_LOCK
ldr r1, =0x0000FFFF
str r1, [r0]
str r1, [r0, #4] ; MPLL_LOCK
str r1, [r0, #8] ; EPLL_LOCK
;当CPU时钟 != HCLK时,要设为异步模式
ldr r0, =OTHERS
ldr r1, [r0]
bic r1, r1, #0xc0 ; 1100,0000
str r1, [r0]
loop1
ldr r0, =OTHERS
ldr r1, [r0]
and r1, r1, #0xf00
cmp r1, #0
bne loop1
;SYNC667
; MISC_CON[19] = 0
ldr r0, =0x7E00F020 ; CLK_DIV0
ldr r1, =(ARM_RATIO) | (MPLL_RATIO << 4) | (HCLK_RATIO << 8) | (HCLKX2_RATIO << 9) | (PCLK_RATIO << 12)
str r1, [r0]
;2.配置时钟
; 2.1 配置APLL
; 2.1.1 设置APLL
; 2.1.2 MUXAPLL
; 2.1.3 SYNC667
; 2.1.4 DIVAPLL
ldr r0, =0x7E00F00C
ldr r1, =APLL_CON_VAL
str r1, [r0] ; APLL_CON, FOUTAPL = MDIV * Fin / (PDIV*2^SDIV) = 266*12/(3*2^1) = 532MHz
;2.2 配置MPLL
; 2.2.1 设置MPLL
; 2.2.2 MUXMPLL
; 2.2.3 SYNCMUX
; 2.2.4 SYNC667
; 2.2.5 HCLKX2_RATIO
; 2.2.6 PCLK_RATIO
ldr r0, =0x7E00F010
ldr r1, =MPLL_CON_VAL
str r1, [r0] ; MPLL_CON, FOUTMPL = MDIV * Fin / (PDIV*2^SDIV) = 266*12/(3*2^1) = 532MHz
;3.选择PLL的输出作为时钟源
ldr r0, =0x7E00F01C
ldr r1, =0x03
str r1, [r0]
mov pc, lr
ldr sp, =8*1024
bl main
halt
b halt
END
|