This document introduces how to use hardware PWM.
By default, the DTS configuration file specifies
PWM_F as the pin used to control the backlight of a VBO screen.
The following code modification is required:
diff --git a/arch/arm64/boot/dts/amlogic/kvim4.dts b/arch/arm64/boot/dts/amlogic/kvim4.dts
- Export PWM
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip4/export
- Configure PWM period
root@Khadas:~# echo 1000000 > /sys/class/pwm/pwmchip4/pwm1/period
- Configure PWM duty cycle
root@Khadas:~# echo 500000 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle
- Enable PWM
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip4/pwm1/enable
- Disable PWM
root@Khadas:~# echo 0 > /sys/class/pwm/pwmchip4/pwm1/enable
If you successfully turn on the hardware pwm, you can see the waveform through the oscilloscope:
If you use an oscilloscope to check the waveform, remember that the board and the oscilloscope need to share the same ground.