|
刚学430不久,写了个定时器输出PWM波的程序,但就是不起作用下面附上程序,望哪位前辈路过,指点一下
#include
#define uint unsigned int
void init_clk(void)
{
unsigned int i;
BCSCTL1=0x00;
do
{
IFG1&=~OFIFG;
for(i=0xff;i>0;i--);
}
while((IFG1&OFIFG));
BCSCTL2=0X00;
BCSCTL2=SELS+SELM_3;
}
void init_pwm(void)
{
P1SEL |= BIT2 + BIT3 ; //选择 p1.2-TA1 ,P1.3-TA2 作为PWM输出 第二功能
P1DIR |= BIT2 + BIT3 ;
TACCR0 = 8000; //PWM信号频率10KHZ
TACCTL1 = OUTMOD_7;
TACCR1 =4000 ; // 占空比1:1
TACCTL2 = OUTMOD_7;
TACCR2 = 4000 ;
TACTL=TASSEL_1 +MC_1;
_BIS_SR(CPUOFF+GIE);
}
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR = 0XFF;P1OUT = 0XFF;
P2DIR = 0XFF;P2OUT = 0XFF;
P3DIR = 0XFF;P3OUT = 0XFF;
P4DIR = 0XFF;P4OUT = 0XFF;
P5DIR = 0XFF;P5OUT = 0XFF;
P6DIR = 0XFF;P6OUT = 0XFF;
init_clk();
init_pwm();
while(1);
}
|
|