BeagleBone Black (v4.14) 上的 PWM
PWM on BeagleBone Black (v4.14)
关于如何在较新版本的内核上为 PWM 配置 Beaglebone 的信息很少。 Past instructions for interfacing with PWM through the slots file are obsolete, as the slots file and bone_capemgr are disabled in v4.14 的内核。
如何使用新内核为 BeagleBone Black 配置 PWM? 我使用的是 TI AM335x BeagleBone Black Wireless 运行 内核版本 4.14.37-ti- r46.
正如问题中提到的,插槽文件和 bone_capemgr 是 disabled in v4.14 of the kernel in favor of U-Boot overlays。
如 response by the BeagleBone kernel developer 中所述,U-Boot 现在处理覆盖并自动启用 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#>..
因此,PWM接口已经配置好了!现在只需导出并使用 PWM。例如访问 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
注意:如果引脚已在使用,您可能需要在 /boot/uEnv.txt
中使用 disable_uboot_overlay_video=1
禁用 HDMI。
要确定 PWM 接口的引脚映射,请参阅我的后续 post 。
Debian 的 BeagleBone 的 last image(Debian 10.3 破坏者)为我们提供了 pwm 输出的下一个引脚映射:
P8.13 corresponds to folder: /sys/class/pwm/pwm-6:1
P8.19 corresponds to folder: /sys/class/pwm/pwm-6:0
P9.14 corresponds to folder: /sys/class/pwm/pwm-3:0
P9.16 corresponds to folder: /sys/class/pwm/pwm-3:1
P9.21 corresponds to folder: /sys/class/pwm/pwm-1:1
P9.22 corresponds to folder: /sys/class/pwm/pwm-1:0
P8.13、P8:19、P9.14、P9.16的默认周期为500000,而P9.21、P9.22的默认周期为20000。
使用 PWM 的关键是下一条指令,在上一篇 post 的 link post 中提到了关于 PWM 接口的引脚映射:
config-pin P8.13 pwm
config-pin P8.19 pwm
config-pin P9.14 pwm
config-pin P9.16 pwm
config-pin P9.21 pwm
config-pin P9.22 pwm
完成之后,为所有需要的 PWM 输出做这个:
debian@beaglebone:~$ cd /sys/class/pwm/pwm-6:1
debian@beaglebone:~$ echo 250000 > duty_cycle
debian@beaglebone:~$ echo 1 > enable
关于如何在较新版本的内核上为 PWM 配置 Beaglebone 的信息很少。 Past instructions for interfacing with PWM through the slots file are obsolete, as the slots file and bone_capemgr are disabled in v4.14 的内核。
如何使用新内核为 BeagleBone Black 配置 PWM? 我使用的是 TI AM335x BeagleBone Black Wireless 运行 内核版本 4.14.37-ti- r46.
正如问题中提到的,插槽文件和 bone_capemgr 是 disabled in v4.14 of the kernel in favor of U-Boot overlays。
如 response by the BeagleBone kernel developer 中所述,U-Boot 现在处理覆盖并自动启用 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#>..
因此,PWM接口已经配置好了!现在只需导出并使用 PWM。例如访问 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
注意:如果引脚已在使用,您可能需要在 /boot/uEnv.txt
中使用 disable_uboot_overlay_video=1
禁用 HDMI。
要确定 PWM 接口的引脚映射,请参阅我的后续 post
Debian 的 BeagleBone 的 last image(Debian 10.3 破坏者)为我们提供了 pwm 输出的下一个引脚映射:
P8.13 corresponds to folder: /sys/class/pwm/pwm-6:1
P8.19 corresponds to folder: /sys/class/pwm/pwm-6:0
P9.14 corresponds to folder: /sys/class/pwm/pwm-3:0
P9.16 corresponds to folder: /sys/class/pwm/pwm-3:1
P9.21 corresponds to folder: /sys/class/pwm/pwm-1:1
P9.22 corresponds to folder: /sys/class/pwm/pwm-1:0
P8.13、P8:19、P9.14、P9.16的默认周期为500000,而P9.21、P9.22的默认周期为20000。
使用 PWM 的关键是下一条指令,在上一篇 post 的 link post 中提到了关于 PWM 接口的引脚映射:
config-pin P8.13 pwm
config-pin P8.19 pwm
config-pin P9.14 pwm
config-pin P9.16 pwm
config-pin P9.21 pwm
config-pin P9.22 pwm
完成之后,为所有需要的 PWM 输出做这个:
debian@beaglebone:~$ cd /sys/class/pwm/pwm-6:1
debian@beaglebone:~$ echo 250000 > duty_cycle
debian@beaglebone:~$ echo 1 > enable