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.

MSP430FR2355: PWM using TIMER in continuous mode?

Part Number: MSP430FR2355


Hello.

I am trying to use output mode 3 for TB1 in continuous mode (Fig. 14-13 UG).  It seems to suggest that TBxR will count to a terminal count based on the whether 12, 16, etc bits. (CNTL bits in TBxCTL).  The resource explorer doesn't show an example for continuous mode PWM.  I have the following code and it sets all the registers as expected.  Can someone tell me what registers I am setting incorrectly?  I seem to get outputs that look like UP mode instead of CONTINOUS even with the MODE appropriately confirmed in the register.

    TimerSetup.pTimerx = TIMERB1;
    TimerSetup.Timer_Config.Pwm[0] = PWM_CCR1;
    TimerSetup.Timer_Config.Pwm[1] = PWM_CCR2;
    TimerSetup.Timer_Config.PwmAction[0] = SET_RESET;
    TimerSetup.Timer_Config.PwmAction[1] = SET_RESET;
    TimerSetup.Timer_Config.PwmOnEdgeTime[0] = 3500;
    TimerSetup.Timer_Config.PwmOnEdgeTime[1] = 3000;
    TimerSetup.Timer_Config.TimerCountDirection = CONT;
    TimerSetup.Timer_Config.TimerSrc = ACLK;
    TimerSetup.Timer_Config.pTimer_Interval.Timer_Unit = MILLISECONDS;
    TimerSetup.Timer_Config.pTimer_Interval.Timer_Interval = 4000;
    TimerSetup.Timer_Config.IRQ = CCR0;

Basically at 4000 ms the output turns off and at PWM_CCR1 turns on at 3500ms and CCR2 turns on at 3000ms.

Thanks

  • Follow up....

    Changing Timer_Interval to 2100ms, PwmOnEdgeTime[0] = 1900 and PwmOnEdgeTime[1] = 1700 doesn't change anything.....

    I was expecting based on the UG pic a 200ms on pulse and a period of 4 seconds.  ACLK (32768) is divided by 2 because 2100ms is > 2seconds so terminal count in this instance would be 4 seconds.  My results on scope show a 2100ms period.

  • In output mode 3 the output will turn on when the count reaches CCR1-x and turn off when it reaches CCR0. (Not the terminal count in continuous mode.) The timer will then continue to count up until it rolls over. From your description it appears to be doing that.

  • Hi David....

    Yes I understand that it is supposed to do that however in my case it turns off when it reaches CCR0

        TimerSetup.pTimerx = TIMERB1;
        TimerSetup.Timer_Config.Pwm[0] = PWM_CCR1;
        TimerSetup.Timer_Config.Pwm[1] = PWM_CCR2;
        TimerSetup.Timer_Config.PwmAction[0] = SET_RESET;
        TimerSetup.Timer_Config.PwmAction[1] = SET_RESET;
        TimerSetup.Timer_Config.PwmOnEdgeTime[0] = 1900;
        TimerSetup.Timer_Config.PwmOnEdgeTime[1] = 1700;
        TimerSetup.Timer_Config.TimerCountDirection = UP;
        TimerSetup.Timer_Config.TimerSrc = ACLK;
        TimerSetup.Timer_Config.pTimer_Interval.Timer_Unit = MILLISECONDS;
        TimerSetup.Timer_Config.pTimer_Interval.Timer_Interval = 4500;
        TimerSetup.Timer_Config.IRQ = CCR0;
    

    Using above code my divider to ACLK (32768) is 4 = 8192Hz....This means terminal count 65535 is 8 seconds.  My TB1CCRx registers are as expected...see below.  My scope shows the correct on time for both CCR2 (4500ms - 1700ms = 2.8 seconds) and CCR1 (4500ms - 1900ms = 2.6 seconds).  What I don't understand though is the scope shows the period of the waves as 4.5 seconds (4500ms) NOT 8 seconds which is terminal count.  The question is why? What am I doing wrong here?

    Thanks

  • You show that the counter mode is "UP". Which would be why.

  • Yup...ughhh!.....Thank you very much....Serious oversight there.

    I am getting expected results....

**Attention** This is a public forum