/*定时器输出单元举例:
ACLK时钟频率为LFXT1=32768Hz,利用Timer_A输出周期为512/32768
=15.625ms,占空比分别为75%和25%的PWM波
*/
#include "io430.h"
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
TACTL=TASSEL_1+TACLR;
CCR0=512-1;//PWM周期
CCTL1=OUTMOD_7;
CCR1=384;//384/512=0.75
CCTL2=OUTMOD_7;
CCR2=128;//占空比128/512=0.25
P1DIR|=BIT2;
P1SEL|=BIT2;
P2DIR|=BIT0;
P2SEL|=BIT0;
TACTL|=MC_1;//增计数模式
while(1)
{
LPM3;
}
return 0;
} |