如何在 BeagleBoneBlack 的 sysfs 中正确使用 PWM?

发布于 2025-01-12 16:53:02 字数 1168 浏览 5 评论 0原文

我想用我的 beagleboneblack 通过 PWM 控制 LED 亮度。

为了在我的 yocto 构建中启用 PWM,我完成了以下步骤:

  1. 在内核 menuconfig 中启用 PWM (bitbake -c menuconfig virtual/kernel)
  2. 修补设备树
diff --git a/am335x-boneblack.dts b/am335x-boneblack.dts index e2ee8b8..8d36bfb 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts @@ -167,3 +167,21 @@       "NC",       "NC";  };
+
+&ehrpwm2 {
+    status = "okay";
+};
+
+&epwmss2 {
+    status = "okay";
+};
+
+&ehrpwm1 {
+    status = "okay";
+};
+
+&epwmss1 {
+    status = "okay";
+};
  1. 使用In /sys/class/pwm< /code>

cd pwmchip0

echo 0 >导出

cd pwm0

echo 200000>周期

echo 100000> Duty_cycle

echo 1 >启用

之后,我将 LED 连接到 P9_22 端口,但没有任何效果。 此外,更改 duty_cycle 不会产生任何影响。

带有调试输出的图像 (cat /sys/kernel/debug/pwm)

我是否做错了什么或者我选择了错误的端口?

预先致以

问候,长

I want to control LED brightness with PWM with my beagleboneblack.

To enable PWM in my yocto build I've done following steps:

  1. Enabled PWM in kernel menuconfig (bitbake -c menuconfig virtual/kernel)
  2. Patched device tree with
diff --git a/am335x-boneblack.dts b/am335x-boneblack.dts index e2ee8b8..8d36bfb 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts @@ -167,3 +167,21 @@       "NC",       "NC";  };
+
+&ehrpwm2 {
+    status = "okay";
+};
+
+&epwmss2 {
+    status = "okay";
+};
+
+&ehrpwm1 {
+    status = "okay";
+};
+
+&epwmss1 {
+    status = "okay";
+};
  1. In /sys/class/pwm

cd pwmchip0

echo 0 > export

cd pwm0

echo 200000 > period

echo 100000 > duty_cycle

echo 1 > enable

After this I connected LED to P9_22 port and nothing works.
Also changing duty_cycle doesn't affect at anything.

Image with debug output (cat /sys/kernel/debug/pwm)

Did I make something wrong or I've chosen wrong port ?

Thanks in Advance

Regards, Long

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文