Just go through the tutorial carefully. Don’t miss the overlays
part.
To check loaded overlays use:
debian@BeagleBone:~$ sudo beagle-version | grep UBOOT
UBOOT: Booted Device-Tree:[k3-am67a-beagley-ai.dts]
UBOOT: Loaded Overlay:[k3-am67a-beagley-ai-pwm-epwm1-gpio20.kernel]
Export header pin 38
(GPIO20) and set the period
and duty_cycle
in nanoseconds. Then enable it:
debian@BeagleBone:~$ sudo beagle-pwm-export --pin hat-38
debian@BeagleBone:~$ echo 20000000 > /dev/hat/pwm/GPIO20/period
debian@BeagleBone:~$ echo 1500000 > /dev/hat/pwm/GPIO20/duty_cycle
debian@BeagleBone:~$ echo 1 > /dev/hat/pwm/GPIO20/enable
With Python File Write api:
def write_file(path, value):
f = open(path, "w")
f.write(str(value))
f.close()
write_file("/dev/hat/pwm/GPIO20/period", 20000000)
write_file("/dev/hat/pwm/GPIO20/duty_cycle", 1500000)
write_file("/dev/hat/pwm/GPIO20/enable", 1)