#include <msp430x14x.h> //#include<intrins.h> #define uint unsigned int void delay(long c); void main( void ) { uint i=0; // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; P2DIR=0x0f; P2OUT=0x0e; while(1) { for(i=0;i<4;i++) { delay(100000); P2OUT<<=1; P2OUT|=0x01; if(P2OUT==0xef) { P2OUT=0x0b; } } //P2OUT=0x0d; for(i=0;i<3;i++) { delay(100000); P2OUT>>=1; P2OUT|=0x08; } P2OUT=0x0e; } } void delay(long c) { while(c--); }
感觉自己对16进制掌握的不太熟悉,调了好一会才出效果