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.

MSP 430g2553 PWM in up/down mode

Other Parts Discussed in Thread: MSP430G2553

Dear  All,

please let me know some sample code about how to generate pwm in up/down mode with pwm values of {0, 31, 59, 81, 95, 100, 95, 81, 59, 31}

Thanks.

  • Dear

    I am getting unwanted pwm in the output with following codes. please advise.

    #include "msp430G2553.h"
    #include <stdint.h>

    unsigned int const pwm[10]={0, 31, 59, 81, 95, 100, 95, 81, 59, 31};
    unsigned int index=0;

    void main( void )
    {
    WDTCTL = (WDTPW | WDTHOLD);

    BCSCTL1 = CALBC1_16MHZ;
    DCOCTL = CALDCO_16MHZ;

    P1SEL = 0x40;
    P1DIR = 0x40;

    TA0CCR0 = (125 - 1);
    TA0CCR1 = 0;
    TA0CCTL1 = OUTMOD_6;
    TA0CTL = (TASSEL_2 | ID_0 | MC_3 | TACLR | TAIE);

    _BIS_SR( GIE );

    while( 1 );
    }

    // Timer0 A1 interrupt service routine
    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void Timer0_A1_ISR( void )
    {
    static int duty = 0;
    TA0CTL &= ~TAIFG;
    if (index < 10)
    {
    duty = pwm[index];
    index++;
    }
    else
    {
    duty = pwm[0];
    index = 1;
    }
    TA0CCR1 = duty;
    }
  • Sun,

    OCY already linked in your other thread about the same topic - please use only one. There is already information in it that people will not see when now continuing the thread here. So please use your other one:

    Dennis

**Attention** This is a public forum