微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > S3C2440 2440init.s分析第一篇(二)

S3C2440 2440init.s分析第一篇(二)

时间:11-20 来源:互联网 点击:
;//2.根据工作频率设置pll

;这里介绍一下计算公式

;//Fpllo=(m*Fin)/(p*2^s)

;//m=Mdiv+8,p=Pdiv+2,s=Sdiv

;The proper range of P and M: 1<=P<=62, 1<=M<=248

;Fpllo必须大于20Mhz小于66Mhz

;Fpllo*2^s必须小于170Mhz

;如下面的PLLCON设定中的M_div P_div S_div是取自option.h中

;#elif (MCLK==40000000)

;#define PLL_M (0x48)

;#define PLL_P (0x3)

;#define PLL_S (0x2)

;所以m=Mdiv+8=80,p=Pdiv+2=5,s=Sdiv=2

;硬件使用晶振为10Mhz,即Fin=10Mhz

;Fpllo=80*10/5*2^2=40Mhz

;To reduce PLL lock time, adjust the LOCKTIME register.

ldr r0,=LOCKTIME

ldr r1,=0xffffff

str r1,[r0]

;//设置PLL的重置延迟

[ PLL_ON_START

; Added for confirm clock divide. for 2440.

; Setting value Fclk:Hclk:Pclk

ldr r0,=CLKdivN

ldr r1,=CLKdiv_VAL ; 0=1:1:1, 1=1:1:2, 2=1:2:2, 3=1:2:4, 4=1:4:4, 5=1:4:8, 6=1:3:3, 7=1:3:6.

str r1,][r0] ;//数据表示分频数

;//Configure UPLL Fin=12.0MHz UFout=48MHz

ldr r0,=UPLLCON

ldr r1,=((U_Mdiv<12)+(U_Pdiv<4)+U_Sdiv) ;//USB PLL CONFIG

str r1,[r0]

nop ;// Caution: After UPLL setting, at least 7-clocks delay must be inserted for setting hardware be completed.

nop

nop

nop

nop

nop

nop

;//Configure MPLL Fin=12.0MHz MFout=304.8MHz

ldr r0,=MPLLCON

ldr r1,=((M_Mdiv<12)+(M_Pdiv<4)+M_Sdiv)

str r1,[r0]

]

;//Check if the boot is caused by the wake-up from SLEEP mode.

ldr r1,=GSTATUS2

ldr r0,[r1]

tst r0,#0x2 ;test if bit[1] is 1 or 0 0->C=1

; 1->C=0

;In case of the wake-up from SLEEP mode, go to SLEEP_WAKEUP handler.

bne WAKEUP_SLEEP ;C=0,jump

EXPORT StartPointAfterSleepWakeUp

StartPointAfterSleepWakeUp

;//3.置存储相关寄存器的程序

;这是设置SDRAM,flash ROM 存储器连接和工作时序的程序,片选定义的程序

;SMRDATA map在下面的程序中定义

;SMRDATA中涉及的值请参考memcfg.s程序

;具体寄存器各位含义请参考s3c44b0 spec

;Set memory control registers

ldr r0,=SMRDATA

ldr r1,=BWSCON ;BWSCON Address

add r2, r0, #52 ;End address of SMRDATA

0

ldr r3, [r0], #4

str r3, [r1], #4

cmp r2, r0

bne %B0

;//set memory registers

;//4.初始化各模式下的栈指针

;Initialize stacks

bl InitStacks

;//5.设置缺省中断处理函数

; Setup IRQ handler

ldr r0,=HandleIRQ ;This routine is needed

ldr r1,=IsrIRQ ;if there isnt subs pc,lr,#4 at 0x18, 0x1c

str r1,[r0]

;//initialize the IRQ 将普通中断判断程序的入口地址给HandleIRQ

;//6.将数据段拷贝到ram中 将零初始化数据段清零 跳入C语言的main函数执行到这步结束bootloader初步引导结束

;If main() is used, the variable initialization will be done in __main().

[ :LNOT:USE_MAIN ;initialized {FALSE}

;Copy and paste RW data/zero initialized data

LDR r0, =|Image$$RO$$Limit| ; Get pointer to ROM data

LDR r1, =|Image$$RW$$Base| ; and RAM copy

LDR r3, =|Image$$ZI$$Base|

;Zero init base => top of initialised data

CMP r0, r1 ; Check that they are different just for debug??????????????????????????

BEQ %F2

1

CMP r1, r3 ; Copy init data

LDRCC r2, ][r0], #4 ;--> LDRCC r2, [r0] + ADD r0, r0, #4

STRCC r2, [r1], #4 ;--> STRCC r2, [r1] + ADD r1, r1, #4

BCC %B1

2

LDR r1, =|Image$$ZI$$Limit| ; Top of zero init segment

MOV r2, #0

3

CMP r3, r1 ; Zero init

STRCC r2, [r3], #4

BCC %B3

]

[ :LNOT:THUMBCODE ;if thumbcode={false} bl main

bl Main ;Dont use main() because ......

b .

]

;//if thumbcod={ture}

[ THUMBCODE ;for start-up code for Thumb mode

orr lr,pc,#1

bx lr

CODE16

bl Main ;Dont use main() because ......

b .

CODE32

]

;function initializing stacks

InitStacks

;Dont use DRAM,such as stmfd,ldmfd......

;SVCstack is initialized before

;Under toolkit ver 2.5, msr cpsr,r1 can be used instead of msr cpsr_cxsf,r1

mrs r0,cpsr

bic r0,r0,#MODEMASK

orr r1,r0,#UNDEFMODE|NOINT

msr cpsr_cxsf,r1 ;UndefMode

ldr sp,=UndefStack ; UndefStack=0x33FF_5C00

orr r1,r0,#ABORTMODE|NOINT

msr cpsr_cxsf,r1 ;AbortMode

ldr sp,=AbortStack ; AbortStack=0x33FF_6000

orr r1,r0,#IRQMODE|NOINT

msr cpsr_cxsf,r1 ;IRQMode

ldr sp,=IRQStack ; IRQStack=0x33FF_7000

orr r1,r0,#FIQMODE|NOINT

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top