#include "msp430g2553.h" #define uint unsigned int //60us延时,8M的晶振 void delay(uint z) { unsigned int i,j; for(i = 0;i<60;i++) for(j=0;j<z;j++) {;;}; } //1us延时,8M的晶振 void delay(unsigned long t) { while ( --t != 0 ); //延时2*t个机器周期 } void main(void) { WDTCTL = WDTPW + WDTHOLD;// Stop watchdog timer //主系统时钟切换为外部高速晶振 if (CALBC1_8MHZ == 0xFF || CALDCO_8MHZ == 0xFF) while(1);// If calibration constants erased, trap CPU!! // Configure Basic Clock BCSCTL1 = CALBC1_8MHZ;// Set range DCOCTL = CALDCO_8MHZ;// Set DCO step + modulation P1DIR|=BIT0;
for(;;) { P1OUT^=BIT0; // Toggle P1.0 using exclusive-OR delay(50000); } }
|