I have a question?
I want to generate TWO pwm signal with SAME duty cycle to drive TWO half bridge MOSFET driver.
After reading so many post related to msp430g2553, i have written the code below for my problem.
can anyone suggest weather the code is correct or am i missing something?
Is there any other efficient method to do the same?
Moreover, i want to change the duty cycle as per need, but i guess the resolution is not better as device frequency is 8 mhz and i want a 200khz pwm,
therefore maximum count value only goes to 40.. how to improve the resolution for the same..
void timer_init(void)
{
/*TIMER_A1 as PWM generation
MSP430G2553 has three CCR registers per TimerA peripheral, allowing each TimerA to produce two PWM outputs with different duty cycles.
TIMER_A0 can generate one duty cycle on P1.2/P1.6 as TA0.2 is not routed to pin in msp430g2553
Timer_A1 can generate two duty cycle on P2.1/P2.2 and P2.4/P2.5
Here Timer_A1 is used to generate two pwm signal with same duty cycle
*/
P2DIR |= BIT1 | BIT2; //set as output pin
P2SEL |= BIT1 | BIT2; //pin selected for special purpose; here for pwm
TA1CCR0 |= 40 - 1; //pwm frequency 200 khz; DCO = MCLK = SMCLK = 8 Mhz
TA1CCR1 |= 26 - 1; //Duty cycle ~63%
TA1CCTL1 |= OUTMOD_7; //set/reset mode
TA1CTL |= TASSEL_2 + MC_1; //SMCLK and up mode count till ccr register
_BIS_SR(LPM0_bits + GIE); //For low power mode and global interrupt
}