我的MCU初始化函数如下:
void MCU_init(void)
{
/*** ### MC68HC908LJ12_64 "Cpu" init code ... ***/
/*** PE initialization code after reset ***/
/* System clock initialization */
/* Common initialization of the write once registers */
/* CONFIG1: COPRS=0,LVISTOP=0,LVIRSTD=0,LVIPWRD=1,SSREC=0,STOP=1,COPD=1 */
CONFIG1 = 0x13;
/* CONFIG2: STOP_IRCDIS=1,STOP_XCLKEN=1,DIV2CLK=0,PCEH=0,PCEL=0,LVISEL1=0,LVISEL0=0 */
CONFIG2 = 0x60;
/* Common initialization of the write once registers */
/* PCTL: BCS=0 */
PCTL &= (unsigned char)~0x10; /* Select clock source from XTAL */
/* PCTL: PLLON=0 */
PCTL &= (unsigned char)~0x20; /* Disable the PLL */
/* PCTL: PLLIE=0,PLLF=0,PLLON=0,BCS=0,PRE1=0,PRE0=0,VPR1=0,VPR0=0 */
PCTL = 0x00; /* Set VCO output Power-of-Two devider P=0 the VCO Power-of-Two multiplier E=0 */
/* PMS: MUL11=0,MUL10=0,MUL9=0,MUL8=0,MUL7=1,MUL6=1,MUL5=1,MUL4=1,MUL3=0,MUL2=1,MUL1=0,MUL0=0 */
PMS = 0xF4; /* Set the Feedback divider N=244 */
/* PMRS: VRS7=1,VRS6=1,VRS5=0,VRS4=1,VRS3=0,VRS2=0,VRS1=0,VRS0=0 */
PMRS = 0xD0; /* Set the VCO Linear multiplier L=208 */
/* PMDS: RDS3=0,RDS2=0,RDS1=0,RDS0=1 */
PMDS = 0x01; /* Set the Reference clock devider R=1 */
/* PBWC: AUTO=1,LOCK=0,ACQ=0 */
PBWC = 0x80; /* Select the operating modes */
/* PCTL: PLLON=1 */
PCTL |= (unsigned char)0x20; /* Enable the PLL */
while(!PBWC_LOCK) { /* Wait */
}
/* PCTL: BCS=1 */
PCTL |= (unsigned char)0x10; /* Select clock source from PLL */
__asm("nop");
__asm("nop");
/* Common initialization of the CPU registers */
/* LVISR: LVIIE=0 */
LVISR &= (unsigned char)~0x40;
/* ### Init_RTC init code */
/* RTCCR1: ALMIE=0,CHRIE=0,DAYIE=0,HRIE=0,MINIE=0,SECIE=1,TB1IE=0,TB2IE=0 */
RTCCR1 = 0x04;
/* RTCCR2: CHRCLR=0,CHRE=0,RTCE=0,XTL2=0,XTL1=0,XTL0=0 */
RTCCR2 = 0x00;
/* ALHR: AH4=0,AH3=0,AH2=0,AH1=0,AH0=0 */
ALHR = 0x00;
/* ALMR: AM5=0,AM4=0,AM3=0,AM2=0,AM1=0,AM0=0 */
ALMR = 0x00;
/* SECR: SEC5=0,SEC4=0,SEC3=0,SEC2=0,SEC1=0,SEC0=0 */
SECR = 0x00;
/* MINR: MIN5=0,MIN4=0,MIN3=0,MIN2=0,MIN1=0,MIN0=0 */
MINR = 0x00;
/* HRR: HR4=0,HR3=0,HR2=0,HR1=0,HR0=0 */
HRR = 0x00;
/* DAYR: DAY4=0,DAY3=0,DAY2=0,DAY1=0,DAY0=1 */
DAYR = 0x01;
/* MTHR: MTH3=0,MTH2=0,MTH1=0,MTH0=1 */
MTHR = 0x01;
/* YRR: YR7=0,YR6=0,YR5=0,YR4=0,YR3=0,YR2=0,YR1=0,YR0=0 */
YRR = 0x00;
/* DOWR: DOW2=0,DOW1=0,DOW0=0 */
DOWR = 0x00;
/* ### */
asm CLI; /* Enable interrupts */
} /*MCU_init*/
|