|
#include
void SetHC(unsigned char a){ P1DIR |= BIT0 + BIT1 + BIT2; //DS ST_CP SH_CP unsigned char i; for(i=0;i<8;i++){ P1OUT &= ~BIT2; if((a & 0x80) == 0x80){ P1OUT |= BIT0; }else{ P1OUT &= ~BIT0; } P1OUT |= BIT2; a<<=1; } P1DIR &= ~(BIT0 + BIT1 +BIT2); }
void OutHC(){ P1DIR |= BIT1; P1OUT &= ~BIT1; P1OUT |= BIT1; }
int main(void) {
WDTCTL = WDTPW + WDTHOLD; // 关闭看门狗 P1DIR &= ~BIT6;//输入测试
SetHC(0xaa);//2级 SetHC(0x0f);//1级 OutHC();
while(1); }
复制代码
|
|