(11)ok6410学习之芯片内部初始化之时钟初始化

一般开发板上带的都是12mhz的外部晶振,然后经过芯片内部倍频后可以达到几百mhz

步骤:

1.配置locktime  :默认,搜索locktime
2.分频:divarm
#define CLK_DIV0 0x7e00f020
#define DIV_VAL ((0x0<<0)|(0x1<<9)|(0x1<<8)|(0x3<<12))//分频系数
        ldr r0, =CLK_DIV0
 ldr r1, =DIV_VAL
 str r1, [r0]
3.如果fclk不等于hclk则必须设置cpu为异步启动模式
#define OTHERS 0x7e00f900
 ldr r0, =OTHERS
 ldr r1, [r0]
 bic r1,r1,#0xc0
 str r1, [r0]
4.配置fclk
#define MPLL_CON 0x7e00f010
#define APLL_CON 0x7e00f00c
#define PLL_VAL ((1<<31)|(266<<16)|(3<<8)|(1<<0))

 ldr r0, =APLL_CON
 ldr r1, =PLL_VAL
 str r1, [r0]
 
 ldr r0, =MPLL_CON
 ldr r1, =PLL_VAL
 str r1, [r0]
5.选择时钟源
#define CLK_SRC 0x7e00f01c
 ldr r0, =CLK_SRC
 mov r1, #0x3
 str r1, [r0]



#define CLK_DIV0 0x7e00f020
#define OTHERS 0x7e00f900
#define MPLL_CON 0x7e00f010
#define APLL_CON 0x7e00f00c
#define CLK_SRC 0x7e00f01c
#define DIV_VAL ((0x0<<0)|(0x1<<9)|(0x1<<8)|(0x3<<12))
#define PLL_VAL ((1<<31)|(266<<16)|(3<<8)|(1<<0))

init_clock:
 ldr r0, =CLK_DIV0
 ldr r1, =DIV_VAL
 str r1, [r0]
 
 ldr r0, =OTHERS
 ldr r1, [r0]
 bic r1,r1,#0xc0
 str r1, [r0]
 
 ldr r0, =APLL_CON
 ldr r1, =PLL_VAL
 str r1, [r0]
 
 ldr r0, =MPLL_CON
 ldr r1, =PLL_VAL
 str r1, [r0]
 
 ldr r0, =CLK_SRC
 mov r1, #0x3
 str r1, [r0]
 
 mov pc, lr

在我的第10课中的代码后面加上该段语句就可以直接初始化时钟了

http://blog.csdn.net/peace1213/article/details/39547761第十课链接点击这即可到达 

共勉,我也是小白 这是我最近的经验

人生得意须尽欢,莫使金樽空对月。




你可能感兴趣的:(OK6410,时钟初始化)