Code One:
1 /**********************************2 program function: Use the key to control the LED lights off3 ***********************************/4#include <msp430x14x.h>5 6 voidint_clk ();7 voidMain ()8 {9Wdtctl = Wdtpw +Wdthold;Ten int_clk (); OneP1dir =0Xf0; AP1out =0Xff; -P6dir =0XFF; -P6out =0x00; the while(1) - { - Switch(P1in &0X0F) - { + Case 0x0e:P 6OUT =0XC0; Break; - Case 0x0d:P 6OUT =0X30; Break; + Case 0x0b:P 6OUT =0X0C; Break; A Case 0x07:P 6OUT =0X03; Break; at } - } - } - - voidINT_CLK () - { inBCSCTL1 &= ~Xt2off; -BCSCTL2 |= selm_1 +SELS; to Do + { -IFG1 &= ~OFIFG; the for(intI= -;i>0; i--) * _nop (); $} while((IFG1 & OFIFG)! =0);Panax NotoginsengIFG1 &= ~OFIFG; -}
Code two:
1#include <msp430x14x.h>2 3 voidint_clk ();4 voidDelayinti);5 voidMain ()6 {7 int_clk ();8 //Initialize IO9P1dir =0XF0;TenP1out =0XFF; OneP6dir =0XFF; AP6out =0XFF; - - if(p1in! =0X0F) the { -Delay -); - if(p1in! =0X0F) - { + Switch(P1in &0X0F) - { + Case 0x0e:P 6OUT =0XFC; Break; A Case 0x0d:P 6OUT =0xf3; Break; at Case 0x0b:P 6OUT =0XCF; Break; - Case 0x07:P 6OUT =0X3F; Break; - } - } - } - Else inP6out =0XFF; - } to + voidINT_CLK () - { theBCSCTL1 &= ~Xt2off; *BCSCTL2 |= selm_1 +SELS; $ DoPanax Notoginseng { -IFG1 &= ~OFIFG; the for(intI=1;i< -; i++) + _nop (); A} while((IFG1 & OFIFG)! =0); theIFG1 &= ~OFIFG; + } - $ voidDelayinti) $ { - while(i--); -}
msp430f149 Learning Path--key