关于如何在较新版本的内核上配置Beaglebone for PWM的信息非常少。我按照PWM on BeagleBone Black (v4.14)的指令与PWM芯片连接,但现在我需要找出每个芯片所连接的引脚。
基于BeagleBone Black documentation中的Cape Expansion Headers图像,我知道:
EHRPWM0A
= P9_22
EHRPWM0B
= P9_21
EHRPWM1A
= P9_14
EHRPWM1B
= P9_16
EHRPWM2A
= P8_19
EHRPWM2B
= P8_13
ECAP0
= P9_42
当我运行ls -lh /sys/class/pwm
以查看可用的PWM接口时,我看到:
lrwxrwxrwx 1 root pwm 0 May 6 14:31 pwmchip0 -> ../../devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0
lrwxrwxrwx 1 root pwm 0 May 6 14:31 pwmchip1 -> ../../devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1
lrwxrwxrwx 1 root pwm 0 May 6 14:31 pwmchip3 -> ../../devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3
lrwxrwxrwx 1 root pwm 0 May 6 14:31 pwmchip5 -> ../../devices/platform/ocp/48304000.epwmss/48304100.ecap/pwm/pwmchip5
lrwxrwxrwx 1 root pwm 0 May 6 14:31 pwmchip6 -> ../../devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip6
当我将其与BeagleBone PWM example进行比较时,我发现可用的芯片和地址是不同的。这个例子确实提到PWM可以改变,所以我需要弄清楚新的映射。
如何确定PWM芯片与引脚的映射?我使用的是运行内核版本为4.14.37-ti-r46的TI AM335x BeagleBone Black Wireless。
答案 0 :(得分:4)
TI AM335x and AMIC110 Sitara Processors Technical Reference Manual的第184页给出了PWM芯片的存储器映射:
PWM子系统0:
0x48300000
eCAP0
:0x48300100
ePWM0
:0x48300200
PWM子系统1:
0x48302000
eCAP1
:0x48302100
ePWM1
:0x48302200
PWM子系统2:
0x48304000
eCAP2
:0x48304100
ePWM2
:0x48304180
每个PWM接口的地址(在问题中公布)包含硬件地址。匹配这些地址给我们:
EHRPWM0
(ePWM0
)是pwmchip1
EHRPWM1
(ePWM1
)是pwmchip3
EHRPWM2
(ePWM2
)是pwmchip6
ECAP0
(eCAP0
)是pwmchip0
每个EHRPWM
芯片有两个PWM输出通道,因此A
和B
变量。它们通过回显0
或1
到export
来导出。这些通道必须使用相同的频率,但可以具有不同的占空比。
因此,根据此接口配置,EHRPWM0A
和EHRPWM0B
位于:
root@beaglebone:~# cd /sys/class/pwm/pwmchip1
root@beaglebone:/sys/class/pwm/pwmchip1# ls
device export npwm power subsystem uevent unexport
导出EHRPWM0A
(P9_22
):
root@beaglebone:/sys/class/pwm/pwmchip0# echo 0 > export
root@beaglebone:/sys/class/pwm/pwmchip0# ls
device export npwm power pwm-1:0 subsystem uevent unexport
导出EHRPWM0B
(P9_21
):
root@beaglebone:/sys/class/pwm/pwmchip0# echo 1 > export
root@beaglebone:/sys/class/pwm/pwmchip0# ls
device export npwm power pwm-1:1 subsystem uevent unexport
注意:可用的PWM接口和地址列表可能与问题中提供的列表不同,但此方法仍可用于确定最终的引脚映射。