PWM Frequency Limitation

Hello,

I am trying to send pwm commands in Python thanks to the Jetson.GPIO library on the NX Xavier. I have manage to configure pin 33 to use it with pwm and the sample code that is given on the Jetson.GPIO github repository works.

However, when I try to increase the pwm frequency from 50Hz to 100Hz or 1000Hz, the following error gets raised:

File “/usr/lib/python3/dist-packages/Jetson/GPIO/gpio.py”, line 245, in _set_pwm_period
f.write(str(period_ns))
OSError: [Errno 22] Invalid argument

It seems that the error comes from the configuration or from the hardware.
Do you know what changes I should implement to be able to increase the pwm frequency ?
Is there some sort of pwm frequency limitation ?

Thanks

hello ethan.cherki,

there’s clock source provided to the PWM controller, it will have a range of output rate.
PWM driver supports automatically switching PWM clock source based on period requested.
please have a try to configure device tree property for setting require period in hz, i.e. pwm-minimum-frequency-hz
for example,

pwm@3280000 {
    ...
    pwm-minimum-frequency-hz = <*>; /* required rate in Hz */
};

Hi Jerry,

Thanks for your answer. What’s the file that I should modify and where is it located ?

Thanks

hello ethan.cherki,

it’s device tree modification, please access L4T sources via download center.
for example,
$L4T_Sources/r32.4.2/Linux_for_Tegra/source/public/hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-p3509-0000-a00.dtsi

you may also refer to BSP Customization chapter for building device tree files.
please also check Flashing a Specific Partition session for updating kernel device tree by specify the partition name.
thanks

Hello JerryChang,

Thanks for the information. We didn’t find any .dtsi or .dts files on our machine. We have a few .dtb files but there are no line corresponding to the pwm minimum frequency in those files.

We are using tegra 210, does that change anything ? What should we do ?

Thanks

hello ethan.cherki,

may I have your confirmation, which Jetson platform you’re working with?
for example, tegra210 is the chip version of Jetson-TX1 and Nano.
thanks

Hello JerryChang,

Sorry I was confusing with another Jetson board that we have. The board that I am talking about is the Xavier NX . It has tegra 186 files as well as tegra 194 files so I suppose the tegra version in use on the board is either 186 or 194.

However, we don’t have any .dtsi file on this board.

Thanks

hello ethan.cherki,

FYI,
Xavier and NX were based-on same chip version, it’s tegra194.
please access L4T sources via download center for the dtsi files.
thanks

Hi @ethan.cherki and @JerryChang ,

I am using NVIDIA Jetson Nano.

For me, I would like to change a pwm Frequency (on pin-33 of J41) to 800kHz by using a method GPIO.PWM(output_pin, frequency) and facing the exact same error as like on this post.

I have enabled pwm0 (pin-32) and pwm2 (pin-33).

I have downloaded the L4T source file from the link:
L4T Jetson Nano + TX1 R32.4.2 Sources

Q1.
Then, could you please guide me to how could I access and modify this line?

pwm@3280000 {
    ...
    pwm-minimum-frequency-hz = <*>; /* required rate in Hz */
};

hello ds.justin.kim,

this thread is for tracing NX platforms; since you’re working with Nano, suggest you should initial another new discussion thread next time.
please refer to Building the NVIDIA Kernel session to compile device tree sources.
you may also check Flashing a Specific Partition to enable -k commands to update DTB partition.
thanks

1 Like

Hi @JerryChang,

Thank you for the reply and descriptions. I would like to try the way that you suggests. :)