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.

MSP430FR6989: How to create PWM output by Timer B

Part Number: MSP430FR6989

Hello

I would like to use PWM output using timer B7. As in Figure 26-12 of 'MSP430FR58xx, MSP430FR59xx, and MSP430FR6xx Family User's Guide' (SLAU 367O)
I created the following program with reference to Timer_B_outputPWM () of MSP430 DriverLib for MSP430FR5xx_6xx Devices. However, pulse output is impossible. Although the pin is set as a timer, PWM output can not be performed from TB 0.0.

#define TIMER_PERIOD 0x4E20
#define DUTY_CYCLE    0x2710

 param.clockSource = TIMER_B_CLOCKSOURCE_SMCLK;
 param.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_1;
 param.timerPeriod = TIMER_PERIOD;
 param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_0; 
 param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_RESET;
 param.dutyCycle = DUTY_CYCLE;

Please let me know what else to set.

Regards.

  • Hi,

    Please refer below Code Examples for PWM output from Timer_B:
    dev.ti.com/.../
  • Per User Guide (SLAU367o) section 26.2.5.1: "Output modes 2, 3, 6, and 7 are not useful for output unit 0 because EQUn = EQU0."
    That list encompasses pretty much all the "PWM" modes. (Toggle/Reset is OUTMOD=2.)

    It is actually possible to do PWM with CCR0, but it's rather tricky and usually not worth the trouble.

    Try using e.g. TB0.1 instead.

    [Edit: Added a positive suggestion.]

  • Hello

    I want to output PWM output from P6.4 / TB0.0.
    Therefore we referred to Timer_B_outputPWM () of MSP 430 DriverLib for MSP430FR5xx_6xx Devices.
    In this reference example, TB0CCR0 is set as the cycle register and TB0CCR1 is set as the duty register. In this case, can we output PWM from TB 0.0?
    If TB0CCR0 is set to cycle and TB0CR1 is set to duty, will PWM be output from TB0.1?
    I will attach my program. In this case, does PWM output from TB0.1 instead of TB0.0?

    #define TIMER_PERIOD 0x0200
    #define DUTY_CYCLE 0x0100

    Timer_B_outputPWMParam param;

    GPIO_setAsPeripheralModuleFunctionOutputPin(
    GPIO_PUSHMOTOR_IN1L_PORT,
    GPIO_PUSHMOTOR_IN1L_PIN,
    GPIO_PRIMARY_MODULE_FUNCTION);

    param.clockSource = TIMER_B_CLOCKSOURCE_SMCLK;
    param.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_1;
    param.timerPeriod = TIMER_PERIOD;
    param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_1;
    param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_RESET;
    param.dutyCycle = DUTY_CYCLE;

    Timer_B_outputPWM(TIMER_B0_BASE, &param);

    Regards.
  • Supposing that GPIO_PUSHMOTOR_IN1L refers to P6.5 (TB0.1), then I expect this code to put out PWM on that pin.

    As a practical matter, the only signal you can get out of TB0.0 (in Up mode) is a 50% duty cycle square wave (OUTMOD=4) at frequency/2. You can adjust the frequency, but not the duty cycle, so it's not PWM in the usual sense of the word.
  • Hello

    Thank you for your support. I understood.
    The PWM pulse was output from TB 0.1.

    Regards.

**Attention** This is a public forum