智能车制作

标题: mc9s12g128 [打印本页]

作者: wdf    时间: 2012-7-2 16:13
标题: mc9s12g128
谁给个时钟总线初始化
作者: qqhengg    时间: 2012-7-4 16:49
void SetBusCLK_nM(byte nM)
{   
    MMCCTL1=0X00;                       
    PKGCR  =0X06;                       
    DIRECT =0x00;
    IVBR   =0xFF;   
    ECLKCTL=0xC0;   
    CPMUPROT   =0x26;   //停止保护时钟配置寄存器
    CPMUCLKS_PSTP=0;    //
    CPMUCLKS_PLLSEL=1;  //应用PLL      
    //CPMUSYNR   =nM-1;   //设置分频因子  
    CPMUSYNR   =0xc0|(nM-1); //设置分频因子
    CPMUREFDIV =0x80|0x00; //pllclock=2*(1+SYNR)= MHz;
    CPMUPOSTDIV=0x00;   // Set the post divider register      
    CPMUPOSTDIV=0x00;   // Set the post divider register  
    CPMUPLL    =0x10;   // Set the PLL frequency modulation  
    while(CPMUFLG_LOCK == 0);          /* Wait until the PLL is within the desired tolerance of the target frequency */
    CPMUPROT=0x00;            /* Enable protection of clock configuration registers */
}




欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2