PWM Frequency Upper Limitation with Jetson.GPIO

Hi @spatra,

Thank you for the detailed descriptions. Now I am pretty sure that there is an upper limitation on the pwm-2 (pin-33). :-)

Before moving to the conclusion, I would love to share the minimal-test-procedures (for some other fellows) who want to investigate this issue.

Step0. Reboot a Jetson Nano.

sudo reboot

Step1. Enable pwm0 (pin-32) and pwm2 (pin-33) using a command:

sudo /opt/nvidia/jetson-io/jetson-io.py

image

Step2. Check the PWM status.

sudo cat /sys/kernel/debug/pwm

It will probably look like as follows:

platform/7000a000.pwm, 4 PWM devices
    pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
...
    pwm-2   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
...

Step3. Export pwm-0 (pin-32) and pwm-2 (pin-33) using a command:

echo 0 > /sys/class/pwm/pwmchip0/export

echo 2 > /sys/class/pwm/pwmchip0/export

Step4. Check the PWM status.

sudo cat /sys/kernel/debug/pwm

For this time, it will probably look like as follows:

platform/7000a000.pwm, 4 PWM devices
    pwm-0   (sysfs               ): requested period: 0 ns duty: 0 ns polarity: normal
...
    pwm-2   (sysfs               ): requested period: 0 ns duty: 0 ns polarity: normal
...

Step5. Freely change the period and duty_cycle and apply it on the pin.

For example, if you want to set:
*Target: pwm-2 (pin-33 of J41)
*Frequency : 100 kHz
*Duty cycle: 20 %

Please note that the unit of period and duty_cycle is nano-seconds, you just need to type:

frequency 100 kHz (=100000 Hz)
period: 1/100000 seconds (=10000 nano-seconds)
duty_cycle: 2000 nano-seconds (20% of 10000 nano-seconds)

echo 10000 > /sys/class/pwm/pwmchip0/pwm2/period

echo 2000 > /sys/class/pwm/pwmchip0/pwm2/duty_cycle

echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable

Step6. Investigate the PWM Frequency Upper Limitation.

Firstly, we would need to set the duty_cycle as 0 %.

echo 0 > /sys/class/pwm/pwmchip0/pwm2/duty_cycle

Secondly, we would need to decrease the period. For me, I could see an -bash: echo: write error: Invalid argument error between 5333 and 5334 nano-seconds of a period value.

period: 5334 nano-seconds
→ period: 5.334e-6 seconds
→ frequency: 187 kHz (=1/5.334e-6 Hz)

echo 5334 > /sys/class/pwm/pwmchip0/pwm2/period

    (No messages)

echo 5333 > /sys/class/pwm/pwmchip0/pwm2/period

-bash: echo: write error: Invalid argument error

Analysis

I would think that the PWM Frequency Upper Limit (on Jetson Nano) is around 187 kHz.