#include #include "derivative.h" /* include peripheral declarations */ #define LED_D1 PTDD_PTDD0 #define LED_D1_DIR PTDDD_PTDDD0 #define LED_ON 0 #define LED_OFF 1 unsigned char SCANF_SEND_STRINGS[] = "HELLO MCU WORLD"; unsigned char *pSendString = SCANF_SEND_STRINGS; /*************************************************************/ /* 初始化總線時(shí)鐘PEE模式 */ /* 外部晶振頻率為4MHz,總線頻率16MHz */ /*************************************************************/ void INIT_MCG(void) { MCGC2=0x36; while(!MCGSC_OSCINIT); MCGC1=0xb8; while(MCGSC_IREFST); while(MCGSC_CLKST!=0b10); MCGC2_LP = 1; MCGC1 = 0x90; MCGC3 = 0x48; MCGC2_LP = 0; while(!MCGSC_PLLST); while(!MCGSC_LOCK); MCGC1 = 0x10; while(MCGSC_CLKST!=0b11); } void delay(void) { unsigned int i; unsigned int j; for(i = 0; i < 100; i++) for(j = 0; j < 4000; j++); } void main(void) { DisableInterrupts; SOPT1 = 0; INIT_MCG(); EnableInterrupts; /* enable interrupts */ /* include your code here */ LED_D1_DIR = 1; LED_D1 = LED_OFF; //以下為設(shè)置波特率,以及初始化SCI1控制寄存器 SCI1BDH = 0X00; SCI1BDL = 0X68;//波特率設(shè)置為9600 SCI1C1 = 0x00; //設(shè)置SCI1為正常模式,八位數(shù)據(jù)位,無奇偶校驗(yàn) SCI1C2 = 0x08; //允許發(fā)送數(shù)據(jù),禁止中斷功能 while(1) { while((*pSendString) != '