Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1.  
  2. #include <msp430.h>
  3.  
  4.  
  5. int main(void)
  6. {
  7. WDTCTL = WDTPW | WDTHOLD; // Stop WDT
  8.  
  9. // Configure GPIO
  10. P6DIR |= BIT6; // P1.0 output
  11. P6OUT |= BIT6; // P1.0 high
  12.  
  13. P4OUT |= BIT1; // Configure P1.3 as pulled-up
  14. P4REN |= BIT1; // P1.3 pull-up register enable
  15. P4IES |= BIT1; // P1.3 Hi/Low edge
  16. P4IE |= BIT1; // P1.3 interrupt enabled
  17.  
  18. // Disable the GPIO power-on default high-impedance mode to activate
  19. // previously configured port settings
  20. PM5CTL0 &= ~LOCKLPM5;
  21. P4IFG &= ~BIT1; // P1.3 IFG cleared
  22.  
  23. TB0CCTL0 |= CCIE; // TBCCR0 interrupt enabled
  24.  
  25. TB0CCR0 = 25600;
  26. TB0CTL = TBSSEL__ACLK | MC__UP; // ACLK, UP mode
  27.  
  28. __bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupt
  29. __no_operation(); // For debug
  30. }
  31.  
  32. // Timer0_B0 interrupt service routine
  33. #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
  34. #pragma vector = TIMER0_B0_VECTOR
  35. __interrupt void Timer0_B0_ISR (void)
  36. #elif defined(__GNUC__)
  37. void __attribute__ ((interrupt(TIMER0_B0_VECTOR))) Timer0_B0_ISR (void)
  38. #else
  39. #error Compiler not supported!
  40. #endif
  41. {
  42. P6OUT ^= BIT6;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement