How to use 40pins pwm01?

How to use 40pins pwm01?

Hi Towe_Roll

Are you using the devkit or custom board for AGX Orin?
What’s the Jetpack version in use?

Do you want to use it as GPIO Input/Output or PWM output?

Hello KevinFFF,

Currently, I am using a carrier board. Later, I will transfer it to my own base board. The Jetpack version is 36.5 and I am using PWM.

I would like to know what the maximum allowable time period for PWM01 GP_PWM8 is. I attempted to set it to 10,000,000 but failed.

The maximum period of PWM01 (GP_PWM8) on AGX Orin is not fixed; it depends on the PWM parent clock.
On Tegra234, the request fails with -EINVAL if the required divider exceeds the 13-bit hardware limit.

If PWM8 is using 408 MHz as parent clock, the maximum period is only about 5.14 ms, so 10,000,000 ns will fail.
If it is using 19.2 MHz, the maximum period is about 109.2 ms, so 10,000,000 ns should work.

So your failure is most likely because PWM8 is currently using the faster 408 MHz parent clock.
Please check the current parent/rate and switch to a slower parent if you need a longer period.

How can this restriction be modified? Is it the device tree? Are there any references available?

To help you modify the PWM01 period restriction via device tree configuration, I need a few more details about your setup:

  1. Board Model: What is the specific carrier board model you’re using?
  2. Device Tree Configuration: Can you share the current device tree configuration for PWM8 (or the relevant pwm node)?
  3. Current Parent Clock: What is the current parent clock frequency for PWM8 on your system? You can check this with:
    cat /sys/kernel/debug/clk/clk_summary | grep pwm
    
  4. Modification Capability: Are you able to modify the device tree, or do you need to use runtime clock switching instead?

Once you provide these details, I can give you specific guidance on how to adjust the PWM configuration to meet your requirements.

1、Jetson AGX Orin DevKit

2、I’m using the default setting, but I’m not quite sure where to configure this part.;

3、

pwm3 1 1 0 408000000 0 0 50000 Y
pwm8 1 1 0 408000000 0 0 50000 Y
pwm7 0 0 0 136000000 0 0 50000 Y
pwm6 0 0 0 136000000 0 0 50000 Y
pwm5 1 1 0 408000000 0 0 50000 Y
pwm4 0 0 0 136000000 0 0 50000 Y
pwm2 0 0 0 136000000 0 0 50000 Y
pwm1 1 1 0 408000000 0 0 50000 Y

4、I’d like to first switch the clock for verification, and then proceed to configure it in the device tree.

Based on your diagnostics, the issue is clear: PWM8 (pwm01 on the 40-pin header) is currently using a 408 MHz parent clock, which limits the maximum period to approximately 5.14 ms. Your requested period of 10,000,000 ns (10 ms) exceeds this limit, causing the -EINVAL error.

Solution:

Switch PWM8 to a slower parent clock (e.g., 19.2 MHz), which would allow a maximum period of ~109.2 ms—well above your 10 ms requirement.

Steps:

  1. Runtime clock switching (for verification):

    # Switch PWM8 parent clock to 19.2 MHz
    echo 19200000 > /sys/kernel/debug/clk/pwm8/clk_parent
    

    Then test your PWM configuration to confirm it works.

  2. Persistent configuration (device tree):
    Once verified, modify your device tree to set the parent clock permanently. This ensures the configuration persists across reboots.

Your understanding of device tree configuration is correct—this is the right approach. Start with the runtime test, then apply the device tree change for production.

image

Yes, you are using 408MHz frequency from parent clock.

Please check the possible parent clock(clk_possible_parents) before configuring the clock parent(clk_parent) and clock rate(clk_rate).

# cd /sys/kernel/debug/clk/pwm8
# grep "" *
# grep "" *
clk_accuracy:0
clk_duty_cycle:1/2
clk_enable_count:0
clk_flags:CLK_GET_RATE_NOCACHE
clk_max_rate:18446744073709551615
clk_min_rate:0
clk_notifier_count:0
clk_parent:pllp_out0
clk_phase:0
clk_possible_parents:pllp_out0 clk_32k clk_m
clk_prepare_count:0
clk_protect_count:0
clk_rate:408000000

Well, how should I make the changes?

Great question! Based on the diagnosis from the moderators, you’ve confirmed that PWM8 is using the 408 MHz parent clock, which limits your maximum period to ~5.14 ms. To make this change persistent across reboots, you’ll need to modify your device tree.

Before we proceed with the device tree changes, I need a couple of clarifications:

  1. Device Tree File Path: What is the path to your device tree source file? For the Jetson AGX Orin DevKit, it’s typically something like arch/arm64/boot/dts/nvidia/tegra234-p3701-0000-p3737-0000.dts in your kernel source tree. Can you confirm the exact path you’re using?

  2. Runtime Test Confirmation: Have you successfully tested the runtime clock switching command (echo 19200000 > /sys/kernel/debug/clk/pwm8/clk_parent) and confirmed it resolves your PWM period issue? This will help us verify the solution works before making permanent changes.

  3. Parent Clock Preference: Which parent clock would you prefer to use? The moderators mentioned clk_32k (32 kHz, very slow) or clk_m (if available). The 19.2 MHz clock is a good middle ground for your 10 ms period requirement.

Once you provide these details, I can guide you through the specific device tree modifications needed.

Are you a robot?

1、source/hardware/nvidia/t23x/nv-public/tegra234-p3737-0000+p3701.dtsi;

2、no

3、19.2MHZ

Please simply run the following command to configure the clock rate as 19.2MHz.

# echo 19200000 > /sys/kernel/debug/clk/pwm8/clk_rate

image

Okay, it seems this node is read-only.

Could you try the following commands instead?

1. configure the frequency for parent clock
# echo 19200000 > /sys/kernel/debug/bpmp/debug/clk/pwm8/rate

2. check pwm node (if pwmchip3 -> ../../devices/platform/bus@0/32f0000.pwm/pwm/pwmchip)
# ls -l /sys/class/pwm
# cd pwmchip3
# echo 0 > export
# cd pwm0

3. configure the pwm period/duty_cycle
# echo 0 > enable
# echo 10000000 > period
# echo 5000000 > duty_cycle
# echo 1 > enable

Please check if above commands work and output the expected PWM signal in your case.

It seems there’s no 32f0000.pwm in the result of ls -l /sys/class/pwm.

Have you enabled it in device tree and also configured its pinmux before use?

sorry,I don’t have the agx orin devkit at the moment. I used the orin nx devkit instead. Should this be sufficient for verifying the PWM function?