可以用PE生成代码,我生成了一段,供你参考
/* Common initialization of the write once registers */
/* CONFIG1:
COPRS=0,LVISTOP=0,LVIRSTD=0,LVIPWRD=0,LVI5OR3=0,SSREC=0,STOP=0,COPD=1 */
setReg8(CONFIG1, 0x01);
/* CONFIG2: STOPICLKEN=0,STOPRCLKEN=0,STOPXCLKEN=0,OSCCLK1=0,OSCCLK0=0,??=0,CDOEN=0,SCIBDSRC=0 */
setReg8(CONFIG2, 0x00);
/* Common initialization of the write once registers */
/* PCTL: BCS=0 */
clrReg8Bits(PCTL, 0x10); /* Select clock source from XTAL */
/* PCTL: PLLON=0 */
clrReg8Bits(PCTL, 0x20); /* Disable the PLL */
/* PCTL: PLLIE=0,PLLF=0,PLLON=0,BCS=0,PRE1=0,PRE0=0,VPR1=1,VPR0=0 */
setReg8(PCTL, 0x02); /* Set VCO output Power-of-Two devider P=0 the VCO Power-of-Two multiplier E=2 */
/* PMS: ??=0,??=0,??=0,??=0,MUL11=0,MUL10=0,MUL9=1,MUL8=1,MUL7=1,MUL6=1,MUL5=0,MUL4=1,MUL3=0,MUL2=0,MUL1=0,MUL0=1 */
setReg16(PMS, 0x03D1); /* Set the Feedback divider N=977 */
/* PMRS: VRS7=1,VRS6=1,VRS5=0,VRS4=1,VRS3=0,VRS2=0,VRS1=0,VRS0=0 */
setReg8(PMRS, 0xD0); /* Set the VCO Linear multiplier L=208 */
/* PMDS: ??=0,??=0,??=0,??=0,RDS3=0,RDS2=0,RDS1=0,RDS0=1 */
setReg8(PMDS, 0x01); /* Set the Reference clock devider R=1 */
/* PBWC: AUTO=1,LOCK=0,ACQ=0,??=0,??=0,??=0,??=0,??=0 */
setReg8(PBWC, 0x80); /* Select the operating modes */
/* PCTL: PLLON=1 */
setReg8Bits(PCTL, 0x20); /* Enable the PLL */
while(!PBWC_LOCK) { /* Wait */
}
/* PCTL: BCS=1 */
setReg8Bits(PCTL, 0x10); /* Select clock source from PLL */
__asm("nop");
__asm("nop");
/*** End of PE initialization code after reset ***/
把setReg8Bits()函数可以直接设定成PCTL=0x10;这种形式
|