BBB Enabling PWM

From Klaus' wiki
Revision as of 09:34, 24 May 2015 by Klaus (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

NOTE: Still a scratch pad!!!!

These notes are based on the 3.8.13-bone70 complete installation as described over at BBB New Debian Image.

In /opt/source/beaglebone-universal-io you'll find some general device drivers for the BBB.

Since BBB uses the FDT (Flattened Device Tree), where a general driver performs the most of the work, no special driver is needed for PWM.

There are two steps in enabling a device:

1. Setup the multiplexing of the pins (i.e. connect the internal device to a pin accessible on the outside)

2. Setup the peripheral (the internal device such as PWM, GPIO, etc.) to the pin assigned above

Ensure that your general pinmux is setup for defaults by ensuring that the /sys/devices/ocp.N exists. If not then perform:

root@beaglebone$] cd /opt/source/beaglebone-universal-io
root@beaglebone$] echo cape-universaln > /sys/devices/bone_capemgr.*/slots

expect an output with this included:

drwxr-xr-x  3 root root    0 May 24 09:24 P8_07_pinmux.15
drwxr-xr-x  3 root root    0 May 24 09:24 P8_08_pinmux.16
drwxr-xr-x  3 root root    0 May 24 09:24 P8_09_pinmux.17
drwxr-xr-x  3 root root    0 May 24 09:24 P8_10_pinmux.18
drwxr-xr-x  3 root root    0 May 24 09:24 P8_11_pinmux.19
drwxr-xr-x  3 root root    0 May 24 09:24 P8_12_pinmux.20
drwxr-xr-x  3 root root    0 May 24 09:24 P8_13_pinmux.21
drwxr-xr-x  3 root root    0 May 24 09:24 P8_14_pinmux.22
drwxr-xr-x  3 root root    0 May 24 09:24 P8_15_pinmux.23
drwxr-xr-x  3 root root    0 May 24 09:24 P8_16_pinmux.24
drwxr-xr-x  3 root root    0 May 24 09:24 P8_17_pinmux.25
drwxr-xr-x  3 root root    0 May 24 09:24 P8_18_pinmux.26
drwxr-xr-x  3 root root    0 May 24 09:24 P8_19_pinmux.27
drwxr-xr-x  3 root root    0 May 24 09:24 P8_26_pinmux.28
drwxr-xr-x  3 root root    0 May 24 09:24 P9_11_pinmux.29
drwxr-xr-x  3 root root    0 May 24 09:24 P9_12_pinmux.30
drwxr-xr-x  3 root root    0 May 24 09:24 P9_13_pinmux.31
drwxr-xr-x  3 root root    0 May 24 09:24 P9_14_pinmux.32
drwxr-xr-x  3 root root    0 May 24 09:24 P9_15_pinmux.33
drwxr-xr-x  3 root root    0 May 24 09:24 P9_16_pinmux.34
drwxr-xr-x  3 root root    0 May 24 09:24 P9_17_pinmux.35
drwxr-xr-x  3 root root    0 May 24 09:24 P9_18_pinmux.36
drwxr-xr-x  3 root root    0 May 24 09:24 P9_21_pinmux.37
drwxr-xr-x  3 root root    0 May 24 09:24 P9_22_pinmux.38
drwxr-xr-x  3 root root    0 May 24 09:24 P9_23_pinmux.39
drwxr-xr-x  3 root root    0 May 24 09:24 P9_24_pinmux.40
drwxr-xr-x  3 root root    0 May 24 09:24 P9_26_pinmux.41
drwxr-xr-x  3 root root    0 May 24 09:24 P9_27_pinmux.42
drwxr-xr-x  3 root root    0 May 24 09:24 P9_30_pinmux.43
drwxr-xr-x  3 root root    0 May 24 09:24 P9_41_pinmux.44
drwxr-xr-x  3 root root    0 May 24 09:24 P9_42_pinmux.46
drwxr-xr-x  3 root root    0 May 24 09:24 P9_91_pinmux.45
drwxr-xr-x  3 root root    0 May 24 09:24 P9_92_pinmux.47

Now in order to connect the PWM to a pin look up what pin PWM can be output to in the cape-universaln-00A0.dts file. You'll find that you can connect them to P9.14, P9.16, P9.21, and P9.22.

To convince yourself on your choise issue this command:

root@beagelbone$] config-pin -l P9.14

expect this output:

default gpio gpio_pu gpio_pd pwm

Now in order to enable the pwm to the P9.14 pin issue:

root@begalebone$] config-pin P9.14 pwm

To ensure yourself that you've got the PWM connected to the pin issue

root@beaglebone$] cat /sys/devices/ocp.3/P9_14_pinmux.32/state

expect this output

pwm

Now where is the PWM?

Issue

root@beaglebone$] ll /sys/class/pwm/

and expect this

total 0
drwxr-xr-x  2 root root    0 Jan  1  2000 .
drwxr-xr-x 59 root root    0 Jan  1  2000 .. 
--w-------  1 root root 4096 Jan  1  2000 export
lrwxrwxrwx  1 root root    0 May 24 09:30 pwmchip0 -> ../../devices/ocp.3/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0
lrwxrwxrwx  1 root root    0 May 24 09:30 pwmchip2 -> ../../devices/ocp.3/48300000.epwmss/48300100.ecap/pwm/pwmchip2
lrwxrwxrwx  1 root root    0 May 24 09:30 pwmchip3 -> ../../devices/ocp.3/48302000.epwmss/48302200.ehrpwm/pwm/pwmchip3
lrwxrwxrwx  1 root root    0 May 24 09:30 pwmchip5 -> ../../devices/ocp.3/48304000.epwmss/48304200.ehrpwm/pwm/pwmchip5
lrwxrwxrwx  1 root root    0 May 24 09:30 pwmchip7 -> ../../devices/ocp.3/48304000.epwmss/48304100.ecap/pwm/pwmchip7
--w-------  1 root root 4096 Jan  1  2000 unexport