Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <msp430.h>
- #include <intrinsics.h>
- #define BTN BIT1 // Port 1.1
- #define LED BIT0 // Port 1.0
- volatile int n = 0;
- /**
- * main.c
- */
- int main(void)
- {
- WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
- P1DIR &= ~BTN;
- P1OUT |= BTN; // btn pulled up
- P1REN |= BTN; // pull up resistor enabled
- P1IE = BTN;
- P1IES = BTN; // high to low transition
- P1IFG = 0x00;
- P1SEL = BIT4; // enable timerA output on 1.4...
- P1DIR |= BIT4; // ...as output
- TA0CTL = TASSEL_1 | ID_0 | MC_1 | TACLR;
- TA0CCR0 = 326;
- TA0CCR3 = 0;
- TA0CCTL3 = OUTMOD_7;
- __enable_interrupt();
- while(1){}
- }
- #pragma vector = PORT1_VECTOR
- __interrupt void P1_ISR(void) {
- switch(P1IV) {
- case P1IV_P1IFG1:
- if(n >= 326)
- n = 0;
- else {
- TA0CCR3 = n;
- n += 3;
- }
- P1IFG = 0x00;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement