时钟管理

https://blog.csdn.net/u013691997/article/details/23680159

https://www.cnblogs.com/d442130165/p/4913148.html

时钟管理步骤:

    1.初始化:设置时钟开关,不使用PLL=》CLK_SRC0=0

    2.设置锁定时间:APLL_LOCK=0xffff  MPll_LOCK=0xffff,APLL_LOCK等寄存器的地址看芯片手册(这里是为了保证所有的时钟都能够稳定,所以设置成了最大的等待时间,具体PLL后的频率可以跟据芯片参考手册调节:延时时间周期数=晶震频率×延时时间)

    3.设置PLL:APLL_CON(这个跟据需要配置那些时钟来确定,APLL HPLL MPLL 等)

    4.设置分频器:CLK_DIV0=(跟据你对应的时钟需要多大的频率设定)

    5 .设置时钟开关(多路选择器):CLK _SRC0:(具体需要那些PLL)

时钟初始化程序:

1.头文件:clok_h

#ifndef _CLOK_H_

#define _CLOK_H_

#define APLL_LOCK (*((volatile unsigned int *)0xe100000))

#define MPLL_LOCK (*((volatile unsigned int *)0xe100008))

#define APLL_CON) (*((volatile unsigned int *)0xe100100))

#define MPLL_CON) (*((volatile unsigned int *)0xe100008))

#define CLK_SRC0) (*((volatile unsigned int *)0xe100200))

#define CLK_DIV0) (*((volatile unsigned int *)0xe100300))

void clok_init();

#endif

void clock_init(void)

{

CLK_SRC0=0;

APLL_LOCK=0xffff;

MPLL_LOCK=0xffff;

APLL_CON0=(1<<0)|(3<<8)|(0x7d<<16)|1<<32;

MPLL_CON=(......);

CLK_DIV0=0x1413440;

CLK_SRC0=0x10001111;

}

猜你喜欢

转载自blog.csdn.net/xiuxin121/article/details/79908458