# include <ioCC2530.h> #define uint unsigned int #define BUZZER P1_3 //定义BUZZER为P13口控制 void Initial(void) { P1DIR |= 0x08; //P13定义为输出 BUZZER = 0; BUZZER = 1; BUZZER = 1; } void Init_Watchdog(void) { WDCTL = 0x00; //时间间隔一秒,看门狗模式 WDCTL |= 0x08; //启动看门狗 } void SET_MAIN_CLOCK(source) { if(source) { CLKCONCMD |= 0x40; /*RC*/ while(!(CLKCONSTA &0X40)); /*待稳*/ } else { CLKCONCMD &= ~0x47; /*晶振*/ while((CLKCONSTA &0X40)); /*待稳*/ } } void FeetDog(void) { WDCTL = 0xa0; WDCTL = 0x50; } void Delay(uint n) { uint i; for(i=0;i<n;i++); for(i=0;i<n;i++); for(i=0;i<n;i++); for(i=0;i<n;i++); for(i=0;i<n;i++); } void main(void) { SET_MAIN_CLOCK(0) ; Initial(); Init_Watchdog(); Delay(1000); BUZZER=0; Delay(1000); while(1) { //FeetDog(); } //喂狗指令(加入后系统不复位,蜂鸣器不再蜂鸣) } |