void timer_init(void) { P2DIR |= BIT1|BIT4; //set as output pin P2.1/TA1.1(O/P OF CCR1 Register), P2.4/TA1.2(O/P OF CCR2 Register) P2SEL |= BIT1|BIT4; //pin selected for special purpose; here for pwm TA1CTL |= TASSEL_2 + MC_3; //SMCLK and up down mode TA1CCR0 |= 160 ; //pwm frequency 100 khz; DCO = MCLK = SMCLK = 16 Mhz i.e. 16M/160 = 100KHZ TA1CCR1 |= Duty; //VARIABLE Duty cycle TA1CCR2 |= Duty; // VARIBLE Duty Cycle TA1CCTL1 |= OUTMOD_6; // TA1CCR1, toggle/set TA1CCTL2 |= OUTMOD_2; // TA1CCR2, toggle/reset } As per your guideline i have written the timer configuration. is it correct? Pin Diagram: NOTE: I have used TIMER_A1 in UP DOWN MODE and i want the output as shown below.
↧