MSP430 timer PWM 1 mhz

PHOTO EMBED

Mon Sep 26 2022 15:43:18 GMT+0000 (Coordinated Universal Time)

Saved by @saekyuu

/*** Clocks and GPIO set-up would be here and are in the downloadable
example, but have not been shown to reduce the code size ***/

	/*** Timer0_A Set-Up ***/
    TA0CCR0 |= 1000-1;
    TA0CCR1 |= 1;
    TA0CCTL1 |= OUTMOD_7;
    TA0CTL |= TASSEL_2 + MC_1;

	/*** Timer1_A Set-Up ***/
    TA1CCR0 |= 4000-1;
    TA1CCTL0 |= CCIE;
    TA1CTL |= TASSEL_2 + MC_1;

    _BIS_SR(LPM0_bits + GIE);
}

#pragma vector=TIMER1_A0_VECTOR
   __interrupt void Timer1_A0 (void) {

    TA0CCR1 += IncDec_PWM*2;

    if( TA0CCR1 > 998 || TA0CCR1 < 2 )
       IncDec_PWM = -IncDec_PWM;
}
content_copyCOPY

https://coder-tronics.com/msp430-timer-pwm-tutorial/