#include /* * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //Set P1.0 high P1DIR |= BIT0; P1OUT &= ~BIT0; //Increase Clock frequency to ~20 MHz DCOCTL = DCO2 + DCO1 + DCO0; //Same thing as BIT7 + BIT6 + BIT5; BCSCTL1 = RSEL3 + RSEL2 + RSEL1 + RSEL0; BCSCTL2 = 0; BCSCTL3 = 0; //Setup TimerA for PWM TA0CTL = MC0 + MC1 + TASSEL_2; TA0CCTL1 = OUTMOD1; TA0CCTL0 |= CCIE; TA0CCR0 = 100;//Period in # of clocks (/2) TA0CCR1 = 49; //Duty Cycle in # of clock / TA0CCR0 //Configure P1.6 to output TimerA output 1 P1DIR |= BIT6; P1SEL |= BIT6; _BIS_SR(GIE); //Bad way to PWM while(1) { P1OUT ^= BIT0; //stand-in for other computations __no_operation(); } return 0; } //TA0_A1 Interrupt Vector #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A(void) { //Now edit the duty cycle TA0CCR1 = TA0CCR1 + 5; if (TA0CCR1 > TA0CCR0-10 ){ TA0CCR1 = 5; } }