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.

MSP432 PWM setting Output PIN problem

Other Parts Discussed in Thread: MSP432WARE

Hi,

i am using the Timer A0 and set a PWM on PIN 2.4

The frequency ist right and everything works fine. Now i want to use PIN 2.5 instead of 2.4 but that doesnt work.

imer_A_PWMConfig pwmConfig =
{
TIMER_A_CLOCKSOURCE_SMCLK,
TIMER_A_CLOCKSOURCE_DIVIDER_1,
24000,
TIMER_A_CAPTURECOMPARE_REGISTER_1,
TIMER_A_OUTPUTMODE_RESET_SET,
12000
};

MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN5,GPIO_PRIMARY_MODULE_FUNCTION);
MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig);

Any idea?

Next question, is it possible to set two PINs for the same PWM? Like if i use PIN 2.4 and PIN 2.5 together?

The Timer A0 can be assigned to this PINS: 7.3, 2.4, 2.5, 2.6, 2.7

Can all output the PWM signal from Timer A0 at the same time too?

I also testet on the "timer_a_pwm_mode" example and set instead of PIN 2.4 the PIN2.5 and the PWM didnt output on the PIN.

I am using the MSP432 Launchpad in RED (Release) and the example was from the MSP432Ware - 3.40.00.25 

Is there a Bug on the Software/Hardware from TimerA0?

  • The primary module function of P2.5 is TA0.2, but you are configuring the timer's CCR1, which outputs to TA0.1.
  • Hi Clemens,

    so if i configure to TA0.2 would the configuration look like this?

    imer_A_PWMConfig pwmConfig =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    24000,
    TIMER_A_CAPTURECOMPARE_REGISTER_2,
    TIMER_A_OUTPUTMODE_RESET_SET,
    12000
    };

    So it is not possible to configure the PWM so that TA0.0/TA0.1/TA0.2/TA0.3/TA0.4 are connected with the same PWM?
  • You could configure all CCRs with the same duty cycle value. (CCR0 sets the frequency, so you cannot use TAx.0 as PWM output.)
  • Hi Clemens,

    if i understood it right, i cannot configure TA0.0/TA0.1/TA0.2/TA0.3/TA0.4 to have same PWM configured because TIMER_A_CAPTURECOMPARE_REGISTER_ X (TA0.x) can only be assigned to the PIN that the PWM should output.
    Is this right?
  • If a timer module has TA0.0, TA0.1, TA0.2, TA0.3 and TA0.4, you can have four independent hardware PWMs based on the same frequency. CCR0 (TA0.0) sets this frequency. CCR1 (TA0.1), CCR2 (TA0.2), CCR3 (TA0.3) and CCR4 (TA0.4) set the duty-cycle for the PWMs. They can each be different as long as they are within the CCR0 value. Outputting TA0.0 on a pin does not make much sense, only the four PWMs from TA0.1 to TA0.4. The CCR values could be:

    Timer clock 10MHz

    CCR0 = 1000 for a fixed frequency of 10kHz for all four PWMs

    CCR1 = 100 for a duty cycle of 10%

    CCR2 = 250 for a duty cycle of 25%

    CCR3 = 500 for a duty cycle of 50%

    CCR4 = 750 for a duty cycle of 75%


    Dennis

  • Hi Dennis,

    thanks for your answer.

    So how can i configure all 4 PWMs using driverlib?

    Timer_A_PWMConfig pwmConfig =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    1000,
    TIMER_A_CAPTURECOMPARE_REGISTER_0,  <-----------How do i set all 4 TA0.1/TA0.2/TA0.3/TA0.4 ?
    TIMER_A_OUTPUTMODE_SET_RESET,
    1000
    };

    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4,GPIO_PRIMARY_MODULE_FUNCTION);

    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN5,GPIO_PRIMARY_MODULE_FUNCTION);

    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN6,GPIO_PRIMARY_MODULE_FUNCTION);

    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN7,GPIO_PRIMARY_MODULE_FUNCTION);

    MAP_Timer_A_generatePWM(TIMER_A0_MODULE, &pwmConfig);

    So the MSP432 can have 4 PWMs Timers TA0.X/TA1.X/TA2.X/TA3.X. Each of those can genarate 4 Outpus with same Frequency and the dulty cycle could be changed. Did i get it right?

    Thanks,

    Michael

  • Hi,

    so i manage to output 4 PWMs from TA0.x:


    extern Timer_A_PWMConfig pwmConfig =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    24000,
    TIMER_A_CAPTURECOMPARE_REGISTER_1,
    TIMER_A_OUTPUTMODE_RESET_SET,
    12000
    };

    extern Timer_A_PWMConfig pwmConfig2 =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    24000,
    TIMER_A_CAPTURECOMPARE_REGISTER_2,
    TIMER_A_OUTPUTMODE_RESET_SET,
    12000
    };
    extern Timer_A_PWMConfig pwmConfig3 =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    24000,
    TIMER_A_CAPTURECOMPARE_REGISTER_3,
    TIMER_A_OUTPUTMODE_RESET_SET,
    12000
    };
    extern Timer_A_PWMConfig pwmConfig4 =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    24000,
    TIMER_A_CAPTURECOMPARE_REGISTER_4,
    TIMER_A_OUTPUTMODE_RESET_SET,
    12000
    };

    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4,GPIO_PRIMARY_MODULE_FUNCTION);
    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN5,GPIO_PRIMARY_MODULE_FUNCTION);
    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN6,GPIO_PRIMARY_MODULE_FUNCTION);
    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN7,GPIO_PRIMARY_MODULE_FUNCTION);

    MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig);
    MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig2);
    MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig3);
    MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig4);

**Attention** This is a public forum