This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PWM输出为啥没有

Other Parts Discussed in Thread: MSPWARE
 #include <msp430.h> 

/*
 * main.c
 */
int sum=0;
void delay_nms(unsigned int n)
{
unsigned int j;
for(j=0;j<n;j++)
{

__delay_cycles(400);
}
}
void main(void) {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
volatile unsigned int i;
P2DIR|=BIT0;
P2SEL|=BIT0;
P5SEL=BIT2+BIT3;
UCSCTL6&=~XT2OFF;
while(SFRIFG1&OFIFG)
{
UCSCTL7&=~(XT2OFFG+DCOFFG+XT1LFOFFG);
SFRIFG1&=~(OFIFG);
}
UCSCTL4|=SELS_5;
TA1CTL|=TASSEL_2+MC_1+TACLR;
TA1CCR0=2000;
TA1CCR1=sum;
TA1CCTL1=OUTMOD_7;

P1REN|=BIT1;
P1OUT|=BIT1;
P1IES|=BIT1;
P1IFG&=~BIT1;
P1IE|=BIT1;

__bis_SR_register(GIE);
while(1);
}
#pragma vector=PORT1_VECTOR
__interrupt void port1(void)
{
sum=sum+50;
if(sum==200)
sum=0;
P1IFG&=~BIT1;
}