Hi, I need to run 2 PWM and they must not use the CPU, so I'm using the TimerA and TimerB.
On timer A, the PWM is perfect and during the program I just change the register TACCR1 to change the duty cycle. So I tried to do something like timer A, into timer B, but didn't work, I only changed the period, but not the duty cycle.
void main (void)
{
WDTCTL = WDTPW + WDTHOLD;
P2DIR |= 0x0C; // P1.2 and P1.3 output
P2SEL |= 0x0C; // P1.2 and P1.3 TA1/2
TACCR0 = 0x9AB3 - 1; // PWM Period
TACCTL1 = OUTMOD_7; // TACCR1 reset/set
TACCR1 = 0;
// TACCR1 PWM duty cycle
TACTL = TASSEL_2 + ID_2 + MC_1;
/* What do I need to change below, to work the same way as Timer A (above)? */
P4DIR |= 0x0C;
P4SEL |= 0x0C;
TBCCR0 = 0x9AB3 - 1;
TBCCTL0 = OUTMOD_4;
TBCTL = TBSSEL_2 + ID_1 + MC_1 + CLLD_2;
}
Thanks,
Lucas