I’m trying to control the camera’s XHS horizontal sync signal (changing the frequency from 83kHz to 86.31kHz) using PWM on an Orin NX device, but the XHS period and duty cycle I set are completely inconsistent with what I actually measured with an oscilloscope:
XHS_PERIOD_NS = 11586;
XHS_DUTY_NS = 11007;
This is my environment:
$ uname -a
Linux agi 5.15.148-tegra #1 SMP PREEMPT Wed Jul 8 14:13:27 UTC 2026 aarch64 aarch64 aarch64 GNU/Linux
$ cat /etc/nv_tegra_release
# R36 (release), REVISION: 4.3, GCID: 38968081, BOARD: generic, EABI: aarch64, DATE: Wed Jan 8 01:49:37 UTC 2025
# KERNEL_VARIANT: oot
TARGET_USERSPACE_LIB_DIR=nvidia
TARGET_USERSPACE_LIB_DIR_PATH=usr/lib/aarch64-linux-gnu/nvidia
I reused the Orin NX pin as GP_PWM3:
GPIO14(PWM)/GPIO3_PX.03 --> GP_PWM3(pwm3)
PWM controller:
$ sudo cat /sys/kernel/debug/clk/pwm3/clk_parent
pllp_out0
Parent clock:
$ sudo cat /sys/kernel/debug/clk/pwm3/clk_possible_parents
pllp_out0 clk_32k clk_m
$ sudo ls -l /sys/kernel/debug/bpmp/debug/clk/pwm3
total 0
-r-------- 1 root root 0 Jan 1 1970 dvfs
-r-------- 1 root root 0 Jan 1 1970 dvfs_table
-r-------- 1 root root 0 Jan 1 1970 flags
drwxr-xr-x 2 root root 0 Jan 1 1970 fmon
-r-------- 1 root root 0 Jan 1 1970 hz_off
-r-------- 1 root root 0 Jan 1 1970 max_rate
-r-------- 1 root root 0 Jan 1 1970 min_rate
-r-------- 1 root root 0 Jan 1 1970 mrqcount
-rw------- 1 root root 0 Jan 1 1970 mrq_rate_locked
-rw------- 1 root root 0 Jan 1 1970 parent
-r-------- 1 root root 0 Jan 1 1970 possible_parents
-r-------- 1 root root 0 Jan 1 1970 pto_counter
-rw------- 1 root root 0 Jan 1 1970 rate
-r-------- 1 root root 0 Jan 1 1970 refcount
-rw------- 1 root root 0 Jan 1 1970 state
drwxr-xr-x 2 root root 0 Jan 1 1970 vdd_core
$ sudo cat /sys/kernel/debug/bpmp/debug/clk/pwm3/rate
22666667
pwmchip1 does indeed correspond to 32a0000.pwm, and the kernel does indeed accept period=11586 and duty=11007.
$ readlink -f /sys/class/pwm/pwmchip1/device
/sys/devices/platform/bus@0/32a0000.pwm
$ sudo cat /sys/kernel/debug/pwm
platform/39c0000.tachometer, 1 PWM device
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
platform/32e0000.pwm, 1 PWM device
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
platform/32c0000.pwm, 1 PWM device
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
platform/32a0000.pwm, 1 PWM device
pwm-0 (sysfs ): requested enabled period: 11586 ns duty: 11007 ns polarity: normal
platform/3280000.pwm, 1 PWM device
pwm-0 (sysfs ): requested enabled period: 33333333 ns duty: 31666667 ns polarity: normal
sudo grep -i pwm /sys/kernel/debug/clk/clk_summary
pwm8 0 0 0 19200000 0 0 50000 Y
pwm2 0 0 0 19200000 0 0 50000 Y
pwm3 1 1 0 22666667 0 0 50000 Y
pwm7 1 1 0 408000000 0 0 50000 Y
pwm6 0 0 0 204000000 0 0 50000 Y
pwm5 1 1 0 408000000 0 0 50000 Y
pwm4 0 0 0 204000000 0 0 50000 Y
pwm1 1 1 0 3187500 0 0 50000 Y
$ sudo find /sys/kernel/debug/bpmp/debug/clk \
-maxdepth 1 -type d -iname '*pwm*' -printf '%f\n'
pwm8
pwm7
pwm6
pwm5
pwm4
pwm3
pwm2
pwm1
Because the ratio of the actual frequency to my target frequency is approximately 1.846.
159.37 ➗ 86.31 = 1.846
Therefore, I assume there is a frequency deviation of approximately 1.846 times, and set the period and duty cycle as follows:
PWM3_PERIOD_NS=21393
PWM3_DUTY_NS=20324
However, after modifying PWM3_PERIOD_NS=21393 and PWM3_DUTY_NS=20324, the frequency changed to 88.54kHz.
So I continued to increase PERIOD_NS and DUTY_NS. The measured frequency remained at 88.54kHz.
PWM3_PERIOD_NS = 21946;
PWM3_DUTY_NS = 20849;
Could you please help me understand what this means? How do I modify it?
Thanks


