2183956_en-US

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

2183956_en-US

2183956_en-US

Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

I was able to configure pin 

MX93_PAD_GPIO_IO05__TPM4_CH0

following this thread: https://community.nxp.com/t5/i-MX-Processors/imx93-GPIO-to-use-as-output-PWM-signal/m-p/1975360 

It worked as pwm with the /sys/class/pwm/pwmchipX/pwm0 handle.

However, I cannot configure pin 

MX93_PAD_GPIO_IO04__TPM3_CH0

to behave the same way. I can create the same handle for channel 0 on a different pwmchip but the LED is lighted up full brightness after boot. With the same set of shell commands to control the /sys/class/pwm/pwmchipX/pwm0, the scope doesn't show any pwm waveforms from  pin 7 of the J1001 connector which is wired to the green LED

jc2025_0-1760108582444.png

jc2025_1-1760108676928.png

Do I need to do anything special for pin GPIO_IO05 or something different than GPIO_IO05?

Yocto ProjectRe: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

Hi @jc2025,


For that you should have pull down resistors to avoid turning on the LEDs.

Please try populating R1036, R1037 and R1038 or use the internal pull down resistor of the chip using the next values:

    pinctrl_tpm3: tpm3grp {
        fsl,pins = <
            MX93_PAD_GPIO_IO04__TPM3_CH0 0x59e //0x02
            MX93_PAD_GPIO_IO12__TPM3_CH2 0x59e //0x02
        >;
    };

	pinctrl_tpm4: tpm4grp {
        fsl,pins = <
            MX93_PAD_GPIO_IO05__TPM4_CH0 0x59e //EXP_GPIO_IO05 J1001 29 
            MX93_PAD_GPIO_IO13__TPM4_CH2 0x59e //EXP_GPIO_IO13 J1001 29 
        >;
    };

Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

You are right. The update dts file worked. And I also try using the recommended way of including the original board dts from bsp in the new dts. It worked too. However the leds still came up bright white at the start. How do I make it zero or leds off? Do I tweak the pad configuration?

Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

@jc2025 


https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/iMX93-EVK-PWM-LED/ta-p/1978047


As shown in the iMX93-EVK-PWM_LED document, LEDs are controlled using PWM. The document also includes pictures. 

TPM3_ch0.pngTPM3_ch2.pngTPM4_ch2.png


Even better, after introducing PWM control of LED lights, the document also provides the final LED control method. The LED driver calls the PWM driver, so you only need to control the brightness, and the driver will automatically map to the corresponding PWM value.

led.png


BTW, the imx93-11x11-evk_tpm1234_103025a.dts file is not a good method for modification; the method in the document attachment is clearer. Moreover, if the BSP changes, this device file does not need to be modified. In fact, you don't need to do anything; just put imx93-11x11-evk-pwm.dts and imx93-11x11-evk-pwm-led.dts into the file and compile it. That's what I did.

imx93-11x11-evk-pwm.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright 2022 NXP
 */

#include "imx93-11x11-evk.dts"


&tpm3 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_tpm3>;
        status = "okay";
};


&tpm4 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_tpm4>;
        status = "okay";
};

&iomuxc {

	pinctrl_tpm3: tpm3grp {
        	fsl,pins = <
            	MX93_PAD_GPIO_IO04__TPM3_CH0	0x19e
            	MX93_PAD_GPIO_IO12__TPM3_CH2	0x19e
        	>;
	};

	pinctrl_tpm4: tpm4grp {
        	fsl,pins = <
            	MX93_PAD_GPIO_IO13__TPM4_CH2	0x19e
        	>;
	};
};

imx93-11x11-evk-pwm-led.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright 2022 NXP
 */

#include 
#include "imx93-11x11-evk-pwm.dts"
/ {

        leds {
		compatible = "pwm-leds";

        	led-g {
			label = "Green::TPM3_CH0";
			color = ;
			pwms = <&tpm3 0 5000000 0>;
			max-brightness = <255>;
		};

        	led-b {
			label = "Blue::TPM3_CH2";
			color = ;
			pwms = <&tpm3 2 5000000 0>;
			max-brightness = <255>;
		};

        	led-r {
			label = "Red::TPM4_CH2";
			pwms = <&tpm4 2 5000000 0>;
			color = ;
			max-brightness = <255>;
		};


	};
};

Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

Hi @jc2025,

Thanks to your device tree, I was able to successfully enable the PWM channels.
Using the latest BSP along with your configuration, I executed the following commands:

cd /sys/class/pwm/pwmchip0/

# Configuring the Green LED
echo 0 > export
echo 2000000 > pwm0/period
echo 0 > pwm0/duty_cycle
echo 1 > pwm0/enable

# Configuring the Blue LED
echo 2 > export
echo 2000000 > pwm2/period
echo 0 > pwm2/duty_cycle
echo 1 > pwm2/enable

cd /sys/class/pwm/pwmchip1/

# Configuring the Red LED
echo 2 > export
echo 2000000 > pwm2/period
echo 0 > pwm2/duty_cycle
echo 1 > pwm2/enable

I’ve set the duty cycle to 0 to keep the LEDs turned off. You can adjust the duty cycle value as needed to control brightness or turn them on.

Best regards,
Chavira

Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

I updated the dts and the led stay bright white. PWM has no effects. Attached here is the dts.

Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?After reviewing it, I may need to tweak my dts to match tpm# with the pin's tpm#.Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

@jc2025 

I found the following link which may be useful to you.

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/iMX93-EVK-PWM-LED/ta-p/1978047


Re: Can imx93evk GPIO_IO04 for RGB LED be configured as PWM for dimming?

Hi @jc2025,


Could you please share your device tree?
Also, what BSP (Board Support Package) version are you currently using?

To enable support for TPM3, you’ll need to add the following configuration to your device tree:

&tpm3 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_tpm3>;
        status = "okay";
};

pinctrl_tpm3: tpm3grp {
        fsl,pins = <
            MX93_PAD_GPIO_IO04__TPM3_CH0	0x19e
        >;
    };​

Once this is added, you should see a new PWM device appear. In a previous case, it showed up as pwmchip1. If both PWM channels are active, please check which pwmchip corresponds to the LED RGB.


If you encounter any issues or need further assistance, feel free to reach out.


Best Regards,

Chavira

标记 (1)
无评分
版本历史
最后更新:
‎11-20-2025 11:02 PM
更新人: