1.1 宏定义时钟注释
//宏定义外接时钟,设置时钟很重要
#define EXTAL_IN_XT1_HZ ( 32768)
#define EXTAL_IN_XT2_HZ (4000000)
//宏定义内部REFO,VLO时钟频率
#define VLOCLK_FREQUENCY ( 10000)
#define REFOCLK_FREQUENCY ( 32768)
1.2 时钟来源
switch(clk)
{
case CLOCK_XT1 :g_sClock.CLK.nHZ = EXTAL_IN_XT1_HZ;break;
case CLOCK_VLO :g_sClock.CLK.nHZ = VLOCLK_FREQUENCY;break;
case CLOCK_REFO :g_sClock.CLK.nHZ = REFOCLK_FREQUENCY;break;
case CLOCK_DCO :g_sClock.CLK.nHZ = g_sClock.DCO_FLL_Frequency;break;
case CLOCK_DCO_DIV:g_sClock.CLK.nHZ = g_sClock.DCO_FLL_Frequency;break;
case CLOCK_XT2 :g_sClock.CLK.nHZ = EXTAL_IN_XT2_HZ;break;
default :return;
}
1.3 时钟参数介绍
typedef enum
{
CLOCK_XT1, //XT1
CLOCK_VLO, //内部10K
CLOCK_REFO, //内部32768
CLOCK_DCO, //内部DCO,如果使用内部DCO作为时钟的话,需要先调用DCO_PLLConfig设置DCO频率
CLOCK_DCO_DIV, //DCO分频(分频为1且不允许修改,与DCO同频)
CLOCK_XT2, //XT2
}CLOCK_Source; //时钟源
1.4 时钟分表
|