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.

CC2340R5: how to use one LPGT to send 3 PWM output on different different channel

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi Expert,

want to confirm below due to it's not in example code.

I want to have 3 pwm output with different duty setting. I only want to use 3 channel in LGPT3.

the sysconfig setting is as below.

i can use below to enable 3 channel, right?

PWMTimerLPF3_Object *object = pwm1->object;

object->chNumber = 0;
pwm1 = PWM_open(CONFIG_PWM_0, &params);
if (pwm1 == NULL)
{
/* CONFIG_PWM_0 did not open */
while (1) {}
}

object->chNumber = 1;
pwm11 = PWM_open(CONFIG_PWM_0, &params);
if (pwm11 == NULL)
{
/* CONFIG_PWM_0 did not open */
while (1) {}
}
object->chNumber = 2;
pwm12 = PWM_open(CONFIG_PWM_0, &params);
if (pwm12 == NULL)
{
/* CONFIG_PWM_0 did not open */
while (1) {}
}
object->chNumber = 0;
PWM_start(pwm1);
object->chNumber = 1;
PWM_start(pwm11);

object->chNumber = 2;
PWM_start(pwm12);


object->chNumber = 0;
PWM_setDuty(pwm1, duty);
object->chNumber = 1;
PWM_setDuty(pwm11, duty);
object->chNumber = 2;
PWM_setDuty(pwm12, duty);

But I cannot get it work. So, I think that I may misunderstand something.

BR,

frank

  • Hi Frank,

    Please be aware of this previous E2E thread.  

    Regardless of an object's chNumber, PWMTimerLPF3_open -> PWMTimerLPF3_getPwmChannelNo will select the first valid channelConfig[x].pin (from the ti_drivers_config.c generated by SysConfig) as its pwmChannelNo.  Hence your channel 0 (first) may be functional, but channels 1 and 2 will not be.

    /*
     *  ======== PWMTimerLPF3_getPwmChannelNo ========
     */
    static LGPTimerLPF3_ChannelNo PWMTimerLPF3_getPwmChannelNo(uint_least8_t index)
    {
        LGPTimerLPF3_HWAttrs const *hwAttrs;
        LGPTimerLPF3_Handle handle;
        LGPTimerLPF3_ChannelNo channelNo;
    
        handle  = (LGPTimerLPF3_Handle)&LGPTimerLPF3_config[index];
        hwAttrs = handle->hwAttrs;
    
        /* Find the channel that has been connected to a pin.
         * It's assumed that only one of the ordinary channels have been
         * muxed to a pin.
         */
        if (hwAttrs->channelConfig[0].pin != GPIO_INVALID_INDEX)
        {
            channelNo = LGPTimerLPF3_CH_NO_0;
        }
        else if (hwAttrs->channelConfig[1].pin != GPIO_INVALID_INDEX)
        {
            channelNo = LGPTimerLPF3_CH_NO_1;
        }
        else
        {
            channelNo = LGPTimerLPF3_CH_NO_2;
        }
    
        return channelNo;
    }

    You will need to copy the source\ti\drivers\pwm\PWMTimerLPF3.c file to your workspace and modify accordingly to meet your specific application needs.

    Regards,
    Ryan