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.

Linux: PWM period value conflicts issue

Tool/software: Linux

Hi,

we have a custom board with tda2px SoC.  I have 3 pins that I want to mux as PWM output.

PWM signals: PWMSS1(ehrpwm1A, ehrpwm1B),  PWMSS2(ehrpwm2A)

I added this in dts:

/* Define custom pinmux. */
&dra7_pmx_core {
        ehrpwm2_pins: ehrpwm2_pins {
        pinctrl-single,pins = <
            0x164 ( PIN_OUTPUT | MUX_MODE10 ) /* (R1) E5.30Hz.ehrpwm1A */
                        0x168 ( PIN_OUTPUT | MUX_MODE10 ) /* (R1) F2.60Hz.ehrpwm1B */
        >;
    };
        ehrpwm1_pins: ehrpwm1_pins {
        pinctrl-single,pins = <
                        0x18C ( PIN_OUTPUT | MUX_MODE10 ) /* (R1) C5.15Hz.ehrpwm2A */

        >;
    };
};

/* Enable pwm submodules */
&epwmss0 {
    status = "okay";
    ehrpwm0: pwm@4843e200 {
        pinctrl-names = "default";
        pinctrl-0 = <&ehrpwm2_pins>;
        status = "okay";
        };
};

&epwmss1 {
    status = "okay";
    ehrpwm1: pwm@48440200 {
        pinctrl-names = "default";
        pinctrl-0 = <&ehrpwm1_pins>;
        status = "okay";
        };
};


Under PWMSS1 I am able to configure only one, ehrpwm1A or ehrpwm1B. When I tried to configure period for another one I got this error:

ehrpwm 4843e200.pwm: Period value conflicts with channel 1

What does it mean? Is it possible to configure different periods, duty_cycles for ehrpwm1A and ehrpwm1B?

Also, this is my shell script with configuration:

PWM60=/sys/class/pwm/pwmchip0
PWM30=/sys/class/pwm/pwmchip0
PWM15=/sys/class/pwm/pwmchip2

echo 1 > ${PWM60}/export
echo 16666666 > ${PWM60}/pwm1/period
echo 1666666 > ${PWM60}/pwm1/duty_cycle
echo 1 > ${PWM60}/pwm1/enable

echo 0 > ${PWM30}/export
echo 33333333 > ${PWM30}/pwm0/period
echo 3333333 > ${PWM30}/pwm0/duty_cycle
echo 1 > ${PWM30}/pwm0/enable

echo 1 > ${PWM15}/export
echo 66666666 > ${PWM15}/pwm1/period
echo 6666666 > ${PWM15}/pwm1/duty_cycle
echo 1 > ${PWM15}/pwm1/enable

Regards.

Nevena Stojanovic




  • Hi Nevena,

    I don't have experience with the PWM, I've just checked the TRM chapter PWMSS.  Looks to me like the two outputs are linked to common counter(s), therefore different periods (that is, frequencies) will not be possible. Kindly refer to TRM figures starting with Figure 29-26. Up, Single Edge Asymmetric Waveform, With Independent Modulation on EPWMxA and EPWMxB—Active High

     

    regards,

    Stan

  • Hi
    Also the alias PWM30/PWM60 you have used in your scripts both map to same instance, is that intentional
  • Hi,

    yes, that was my intention.  So,  /sys/class/pwmchip0 is one instance, and A pins refers to /sys/class/pwmchip0/pwm0 and B pins refers to /sys/class/pwmchip0/pwm1. I can use both ehrpwm1A and ehrpwm1B  with the same period, and I can set different duty_cycles. But, I need to set different periods for those pins and when I tried  to do that I got the previous error with period conflicts. 

    So, the conclusion is that two A and B outputs under one instance of PWMSSx can be used independently only if they have the same period?

    Regards.

    Nevena Stojanovic

  • Yes, output B is there more to complement output A for various usecases, than to use as another PWM driver. One usecase example could be driving a H-bridge for DC motor control.
    I hope you have access also to the third PWM instance output for your needs.

    Regards,
    Stan