PB:Enabling and disabling I/O
Over at Adafruit is a great introduction to the Device Tree, that is used on BeagleBones.
BeagleBone black originally came with a kernel 3.8 which had a Device Tree Overlay (DTO) and a capemanager. But in the newer kernels, at time of writing 4.9, the DTO has been completely reorganised and there is no need for at capemanager any more.
For kernels newer or equal to 4.9 follow the guideline below.
Rober Nelson has written a short guide to enable a few of the most used IO's. The rest should be deductable if you combine the pin configuration seen below and the commands given.
The IO is available through a virtual filesystem starting in /sys.
Switch to user root.
] $ su -
The utility config-pin can setup the configuration.
In order to send pwm output from PWM chip0 through the pinmux to pin 1,35 issue this command:
] $ config-pin p1_36 pwm
After the config-pin utility has been executed change to this directory
] $ cd /sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip0/
The PB has two PWM chips on board. Chip0 and Chip1. In order to enable Chip0 perform
] $ echo 0 > export
Now the chip0 is enabled which will reveal a pwm0 directory in current directory.
Change into the directory and list the files available.
[ ✗ root@beaglebone [pwm0] $ ll total 0 drwxr-xr-x 3 root root 0 Mar 9 10:51 . drwxrwxr-x 4 root pwm 0 Mar 9 10:50 .. -r--r--r-- 1 root root 4.0K Mar 9 10:51 capture -rw-r--r-- 1 root root 4.0K Mar 9 11:05 duty_cycle -rw-r--r-- 1 root root 4.0K Mar 9 10:56 enable -rw-r--r-- 1 root root 4.0K Mar 9 11:04 period -rw-r--r-- 1 root root 4.0K Mar 9 10:51 polarity drwxr-xr-x 2 root root 0 Mar 9 10:51 power -rw-r--r-- 1 root root 4.0K Mar 9 10:51 uevent
provided you've made an alias called ll in root home directory in the file .bashrc - otherwise use ls -al
Write a "1! into the enable file in order to enable the pwm.
Write the desired period time for the pwm signal into period
Write the desired duty cycle into duty_cycle
[ ✓ root@beaglebone [pwm0] $ echo 1 > enable [ ✓ root@beaglebone [pwm0] $ echo 1000000000 > period [ ✓ root@beaglebone [pwm0] $ echo 500000000 > duty_cycle
The is the result: