msp430f149 Learning Path-keys and LEDs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.