Code
1 /***********************************2 program function: Control LED status with key3 Disadvantage: The button can not change the status of the LED after pressing, you may use the Reset button on the board ^~^4 *************************************/5#include <msp430x14x.h>6 7 intK,i=0;8 voidint_clk ();9 voidLedintn);Ten voidMain () One { AWdtctl = Wdtpw +Wdthold; - int_clk (); -P1dir =0Xf0; theP1out =0XFF; -P6dir =0XFF; -P6out =0XFF; - + while(1) - { +P1out =0X0F; A if(p1in! =0X0F) at { - for(intI= -;i>0; i--) - _nop (); - if(p1in! =0X0F) - { - Switch(P1in &0X0F) in { - Case 0x0e: LED (0); Break; to Case 0x0d: LED (1); Break; + Case 0x0b: LED (2); Break; - Case 0x07: LED (3); Break; the } * } $ }Panax Notoginseng } - } the + voidINT_CLK () A { theBCSCTL1 &= ~Xt2off; +BCSCTL2 |= selm_1 +SELS; - Do $ { $IFG1 &= ~OFIFG; - for(intI= -;i>1; i--) - _nop (); the} while((IFG1 & OFIFG)! =0); -IFG1 &= ~OFIFG;Wuyi } the - voidLedintN) Wu { -k=N; AboutTACCTL0 =CCIE; $TACCR0 =50000; -Tactl = Mc_1 +tassel_2; - - _eint (); A } + #pragmaVector = Timera0_vector the__interruptvoidTimera (void) - { $ if(k==0) theP6out = ~ (0X80>> (i++)); the Else if(k==1) theP6out = ~ (0x01<< (i++)); the Else if(k==2) -P6out =0XFF; in Else theP6out =0x00; the About if(i==8) theI=0; the the for(intj= the;j>1; j--) + _nop (); -}
msp430f149 Learning Path-keys and LEDs