PWM on BeagleBone Black (v4.14)

2019-08-15 02:55发布

There is very little information how to configure the Beaglebone for PWM on newer versions of the kernel. Past instructions for interfacing with PWM through the slots file are obsolete, as the slots file and bone_capemgr are disabled in v4.14 of the kernel.

How do I configure PWM for BeagleBone Black with the new kernel? I am using a TI AM335x BeagleBone Black Wireless running kernel version 4.14.37-ti-r46.

1条回答
萌系小妹纸
2楼-- · 2019-08-15 03:48

As mentioned in the question, the slots file and bone_capemgr are disabled in v4.14 of the kernel in favor of U-Boot overlays.

As explained in a response by the BeagleBone kernel developer, U-Boot now handles the overlays and automatically enables the equivalent of cape_enable=bone_capemgr.enable_partno=univ-all,BB-ADC,BB-PWM0,BB-PWM1,BB-PWM2:

All 5 of those are enabled out of the box with the images now shipping under:

https://beagleboard.org/latest-images

For the pwm's make sure to reference https://github.com/beagleboard/bb.org-overlays/blob/master/examples/cape-unversal-pwm.txt and the config-pin pwm <pin#>..

Therefore, the PWM interface is already configured! Now just export and use the PWM. For example to access pwm0:

root@beaglebone:~# cd /sys/class/pwm/pwmchip0
root@beaglebone:/sys/class/pwm/pwmchip0# ls
device  export  npwm  power  subsystem  uevent  unexport

root@beaglebone:/sys/class/pwm/pwmchip0# echo 0 > export
root@beaglebone:/sys/class/pwm/pwmchip0# ls
device  export  npwm  power  pwm-0:0  subsystem  uevent  unexport

root@beaglebone:/sys/class/pwm/pwmchip0# ls pwm-0:0
capture  device  duty_cycle  enable  period  polarity  power  subsystem  uevent

Note: you might need to disable HDMI with disable_uboot_overlay_video=1 in /boot/uEnv.txt if the pins are already in use.

To determine the pin mapping for the PWM interfaces, see my follow-up post PWM chip to pin mapping on BeagleBone Black (v4.14).

查看更多
登录 后发表回答