P1DIR |= BIT6; // 选择P1.6的第二功能,即TA0.1
P1SEL |= BIT6;
CCR0 = 7; // PWM 周期 = ACLK@32768/4KHz-1 = 8.192-1 = 7
CCTL1 = OUTMOD_6; // CCR1 reset/set
CCR1 = 3; // CCR1 PWM 占空比50% =8.192*50% - 1 = 3
TACTL = TASSEL_2 + MC_1; // MCLK, up mode
P2DIR |= BIT2; // 选择P2.2的第二功能,即TA1.0
P2SEL |= BIT2;
P2DIR |= BIT3; // 选择P2.3的第二功能,即TA1.0
P2SEL |= BIT3;
TA1CCR0 = 15; // PWM 周期= ACLK@32768/2KHz-1 = 16-1 = 15
TA1CCTL1 = OUTMOD_4; // CCR1 reset/set
TA1CCR1 = 3; // CCR1 PWM 占空比25% = 16*25% - 1 = 3
TA1CTL = TASSEL_2 + MC_1; // MCLK, up mode
可以产生两路PWM,但是若是改了输出引脚就输出不了,求高手指导~~~万分感谢