Advertisement
Guest User

MSP430 Launchpad led chaser up mode

a guest
Apr 10th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include  <msp430g2553.h>
  2. #define MAX 3000
  3. unsigned int i = 0;                         // Initialize variables. This will keep count of how many cycles between LED toggles
  4.  
  5. void delay()
  6.  {
  7.  for(i=0;i<=MAX;i++);
  8.  }
  9. void main(void)
  10. {
  11.   WDTCTL = WDTPW + WDTHOLD;                
  12.   P1DIR |= BIT0;
  13.   P1DIR |= BIT1;
  14.   P1DIR |= BIT2;
  15.   P1DIR |= BIT3;
  16.   P1DIR |= BIT4;
  17.  
  18.  
  19.  
  20.   P1OUT &= ~BIT0;   // initially i off the bit
  21.   P1OUT &= ~BIT1;
  22.   P1OUT &= ~BIT2;
  23.   P1OUT &= ~BIT3;
  24.   P1OUT &= ~BIT4;
  25.  
  26.   for(;;)
  27.   {
  28.   P1OUT |= BIT0;
  29.   delay();
  30.   P1OUT &= ~BIT0;
  31.    
  32.   P1OUT |= BIT1;
  33.   delay();
  34.   P1OUT &= ~BIT1;
  35.  
  36.   P1OUT |= BIT2;
  37.   delay();
  38.   P1OUT &= ~BIT2;
  39.  
  40.   P1OUT |= BIT3;
  41.   delay();
  42.   P1OUT &= ~BIT3;
  43.  
  44.   P1OUT |= BIT4;
  45.   delay();
  46.   P1OUT &= ~BIT4;
  47.  
  48.   }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement