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.

Generating 50Hz 0-100% Duty Cycle PWM Waveform using Timer_A

Other Parts Discussed in Thread: MSP430F2011, MSP430G2452

#include <msp430f2011.h>
#define _XTAL_FREQ 20000000
unsigned int width=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //turn off the watch dog timer
DCOCTL = CALDCO_16MHZ; //set internal clock speed to 16 MHz
BCSCTL1 = CALBC1_16MHZ; //set internal clock speed to 16 MHz
P1DIR = BIT6;
P1SEL = BIT6;         //TA1
TACCR0 = 40000;    //2000000/40000 = 50hz = 20ms
TACCTL1 = OUTMOD_3; //set/reset
TACCR1 = width; //1.5ms pulse
TACTL = TASSEL_2 + MC_1 + ID_3; //up mode, SMCLK/8

while(1)
{
if(width<40000)
{
width = width+1;
}
else
{
width = 0;
}
TACCR1 = width;
__delay_cycles(100);
}
}

I need help with this PWM  code,it produces a straight line in proteus simulation, maybe there is a problem with the while loop. 

**Attention** This is a public forum