用的是MSP430G2553 管脚上没有TA0.2,不像TA1那样。但是貌似论坛上有人说每路TA都能产生两路PWM波,好奇之余试试···结果没成功。以下是程序:
#include
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
//时钟设置为1MHz mclk=smclk=dco
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
BCSCTL3 |= LFXT1S_2;
BCSCTL2 |=SELM_1 + DIVM_0;
//初始化TA0为两通道pwm,smclk
P1DIR |= (BIT1+BIT2);
P1SEL |= (BIT1+BIT2);
TA0CCR2 = 2000;
TA0CCTL0 = OUTMOD_7;
TA0CCTL1 = OUTMOD_7;
TA0CCR0 = 200;
TA0CCR1 = 1000;
TA0CTL = TASSEL_2 + MC_1;
_BIS_SR(LPM0_bits); //进入LPM0低功耗模式
}
额··没出波形···是不是PWM波周期设置只认CCR0??对哦 没看到哪里可以设置说周期可以设置为CCR1或者CCR2·····那怎么过TA0输出两路PWM呢??膜拜高手解答·······阿弥陀佛····
|