Enable PWM Pins on Jetson Nano

To control IR LED, we required PWM on GPIO07, which supports PWM as per pinmux sheet
We had done the following steps,

  1. Change the gpio pin to pwm pin in pinmux spreadsheet
    2. Rebuild dtb file with updated dtsi files
    3. Device tree flashing with updated dtb files
    4. Use the debugfs to control the pwm

But using the below steps, we didn’t get PWM signal on the required pin

#with sudo permission
echo 0 > /sys/devices/7000a000.pwm/pwm/pwmchip0
echo 10000 > /sys/class/7000a000.pwm/pwmchip0/pwm0/period
echo 2000 > /sys/class/7000a000.pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/7000a000.pwm/pwmchip0/pwm0/enable

We referred to the below post
What pins can be used for PWM control except 33 in samples - #24 by 970905326 and executed the following commands and after that PWM worked fine

# Enable Pin 32 / PWM0
busybox devmem 0x700031fc 32 0x45
busybox devmem 0x6000d504 32 0x2

Could you please clarify if any additional configurations are needed other than pin muxing and exporting pin using sysfs entries to enable PWM without the above two steps of register writes, how we get pin-number for PWM as we are using GPIO07 as per above-mentioned post it comes under pin32, and what is the Upper and Lower Limit of PWM Frequency on Jetson Nano?

Sorry for the late response, is this still an issue to support? Thanks

hello krishnaprasad.k,

may I also know which JetPack release you’re using.
you’ll need to update pinmux spreadsheets since GPIO07 it’s by default configure as GPIO pin, i.e. modify GPIO3_PV.00 as PM3_PWM0.
please see-also similar topics for using PWM on Nano.
for example, Topic 122492, Topic 157462.

@JerryChang
Thanks for the response
We are able to get PWM on GPIO07, but we have to do the below steps,

         busybox devmem 0x700031fc 32 0x45
         busybox devmem 0x6000d504 32 0x2

Could you please clarify the above devmem read/write steps are required to enable PWM even though we had exported and enabled the PWM using sysfs? Or anything to be added in during pinmuxing, and What is the Upper and Lower Limit of PWM Frequency on Jetson Nano?

hello krishnaprasad.k,

you may not update pinmux correctly, it’s register write to update pin configuration.

@JerryChang

you may not update pinmux correctly, it’s register write to update pin configuration>

But we have updated the pinmux sheet required for PWM, which is shared below.

Also shared the PWM pin status in the pinmux sheet

Could you please check if anything is wrong from our side?

hello krishnaprasad.k,

how you update the pin configuration? you should at least having partition update to re-flash DTB partition to apply those settings.

furthermore,
you may check the clock sources to review the possible rate of a PWM controller.
let’s assume the clock source is pllp_out0 which has a rate of 102 MHz.
so…
Max Rate = 102Mhz/ 256 = 398437 Hz = 2510 ns
Min Rate = 102Mhz/ (256* 2^13) (i.e. 13-bits Frequency divider (bits 0:12)) = 48.63Hz = 20561324 ns

@JerryChang Thanks for the response

how you update the pin configuration? you should at least having partition update to re-flash DTB partition to apply those settings.>
We have used the following command to flash the device tree only
sudo ./flash.sh -r -k DTB <configfile> mmcblk0p1

furthermore,
you may check the clock sources to review the possible rate of a PWM controller.
let’s assume the clock source is pllp_out0 which has a rate of 102 MHz.>
How we can find the respective clock source for the pin 206 which is PM3_PWM0 as per pinmux sheet configured as PWM?

As per our use case, the same PWM is controlling IR LED By default the state of IR LED is high, Could you please provide clarity on how we can change the state of PWM pin as low by default? Any changes to be made in the pinmux sheet and in device tree as per our use case?

you should configure the pin as Int PD.

			lcd_bl_pwm_pv0 {
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;

@JerryChang Thanks for response

```you should configure the pin as Int PD.
lcd_bl_pwm_pv0 {
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;

As per our use case, we have given the default state of PWM pin as pull up to turn off the IR LED by default as shown below in pinmux sheet

``` lcd_bl_pwm_pv0 {
                                nvidia,pins = "lcd_bl_pwm_pv0";
                                nvidia,function = "pwm0";
                                nvidia,pull = <TEGRA_PIN_PULL_UP>;
                                nvidia,tristate = <TEGRA_PIN_DISABLE>;
                                nvidia,enable-input = <TEGRA_PIN_DISABLE>;
                        };

But it is not reflected, when jetson nano is booted. IR led is still in On by default, it is in Active Low state

When we tried to disable after exporting manually, the PWM and set PWM frequency and duty cycle and given ACTIVE HIGH, it is working fine.

echo 0 > /sys/class/pwm/pwmchip0/export
echo 2500000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 250000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable```
  
Any other solution is there to fix the issue?
Can we give Drive1 instead of Pull Up in the pinmux sheet?

@JerryChang Any suggestion would be helpful to fix the issue

hello krishnaprasad.k,

FYI, the pinmux pin configuration.
PD/PU is to enable resistor of pull-up/down; Drive 0/1 is to enable CMOS output low/high.

@JerryChang Thanks for the response

PD/PU is to enable resistor of pull-up/down; Drive 0/1 is to enable CMOS output low/high.

Could you please clarify more on the above point, how it impacts the default state of a GPIO/PWM pin when we configure GPIO/PWM signal as pull-up/down or Drive 0/1 in the pinmux sheet?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.