QG8小demo板上,初始化代码是由DI自动生成,但是在一执行MCU_Init这后,就提示: Target speed change detected new speed 12.49MHz 我知道是改变了BDM的连接速率,按理应不会啊?另外,BDM不是有后备时钟吗? 不知QG8中有没有?查询数据手册,没找到相关说明。初用9s08系列特别麻烦,一遇到解决不了的问题,就要查阅大量的相关资料,可是资料又少。可以说我们就像一个拓荒者。随便哆嗦两句,以下是MCU_Init代码,请各位指点下: /* ### MC9S08QG8_16 "Cpu" init code ... */ /* PE initialization code after reset */ /* Common initialization of the write once registers */ /* SOPT1: COPE=1,COPT=1,STOPE=0,BKGDPE=1,RSTPE=0 */ SOPT1 = 0xD2; /* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=0,BGBE=0 */ SPMSC1 = 0x18; /* SPMSC2: PDF=0,PPDF=0,PPDACK=0,PDC=0,PPDC=0 */ SPMSC2 = 0x00; /* SPMSC3: LVDV=0,LVWV=0 */ SPMSC3 &= (unsigned char)~0x30; /* System clock initialization */ ICSTRM = *(unsigned char*far)0xFFAF; /* Initialize ICSTRM register from a non volatile memory */ ICSSC = *(unsigned char*far)0xFFAE; /* Initialize ICSSC register from a non volatile memory */ /* ICSC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=0,IREFSTEN=0 */ ICSC1 = 0x04; /* Initialization of the ICS control register 1 */ /* ICSC2: BDIV=1,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 */ ICSC2 = 0x40; /* Initialization of the ICS control register 2 */ /* SOPT2: COPCLKS=0,IICPS=1,ACIC=0 */ SOPT2 = 0x02; /* Common initialization of the CPU registers */ /* PTADD: PTADD5=0 */ PTADD &= (unsigned char)~0x20; /* PTAPE: PTAPE5=1 */ PTAPE |= (unsigned char)0x20; /* PTASE: PTASE4=1,PTASE3=1,PTASE2=1,PTASE1=1,PTASE0=1 */ PTASE |= (unsigned char)0x1F; /* PTBSE: PTBSE7=1,PTBSE6=1,PTBSE5=1,PTBSE4=1,PTBSE3=1,PTBSE2=1,PTBSE1=1,PTBSE0=1 */ PTBSE = 0xFF; /* PTADS: PTADS5=0,PTADS4=0,PTADS3=0,PTADS2=0,PTADS1=0,PTADS0=0 */ PTADS = 0x00; /* PTBDS: PTBDS7=0,PTBDS6=0,PTBDS5=0,PTBDS4=0,PTBDS3=0,PTBDS2=0,PTBDS1=0,PTBDS0=0 */ PTBDS = 0x00; /* ### Init_IIC init code */ /* IICF: MULT1=0,MULT0=1,ICR5=0,ICR4=0,ICR3=0,ICR2=0,ICR1=0,ICR0=0 */ IICF = 0x40; /* IICA: ADDR7=0,ADDR6=0,ADDR5=0,ADDR4=0,ADDR3=0,ADDR2=0,ADDR1=0 */ IICA = 0x00; /* IICS: TCF=0,IAAS=0,BUSY=0,ARBL=1,SRW=0,IICIF=1,RXAK=0 */ IICS = 0x12; /* Clear the interrupt flags */ /* IICC: IICEN=1 */ IICC |= (unsigned char)0x80; /* IICC: IICEN=1,IICIE=0,MST=0,TX=1,TXAK=0,RSTA=0 */ IICC = 0x90; /* ### Init_COP init code */ SRS = 0xFF; /* Clear WatchDog counter */ /* ### Init_IRQ init code */ /* ** Initialize pin PTA5_IRQ_TCLK_RESET ** */ /* IRQSC: IRQIE=0 */ IRQSC &= (unsigned char)~0x02; /* Disable IRQ Interrupt */ /* IRQSC: IRQACK=1 */ IRQSC |= (unsigned char)0x04; /* ### Init_GPIO init code */ /* PTADD: PTADD3=0,PTADD2=0 */ PTADD &= (unsigned char)~0x0C; /* ### Init_MTIM init code */ /* MTIMMOD: MOD=0 */ MTIMMOD = 0x00; /* MTIMCLK: CLKS=0,PS=0 */ MTIMCLK = 0x00; /* MTIMSC: TOF=0,TOIE=0,TRST=0,TSTP=1 */ MTIMSC = 0x10; /* ### Init_GPIO init code */ /* PTBDD: PTBDD5=0 */ PTBDD &= (unsigned char)~0x20; /* ### */ asm CLI; |