Difference between revisions of "PB:Enabling and disabling I/O"

From Klaus' wiki
Jump to: navigation, search
Line 6: Line 6:
  
 
For kernels newer or equal to 4.9 follow the guideline below.
 
For kernels newer or equal to 4.9 follow the guideline below.
 +
 +
[https://github.com/beagleboard/pocketbeagle/wiki/Peripherals 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.
 +
 +
[[File:PocketBeagle pinout.png|600 px]]
 +
 +
The IO is available through a virtual filesystem starting in /sys.
 +
 +
===Enabling PWM===
 +
 +
Switch to user root.
 +
<source lang=bash>
 +
] $ su -
 +
</source>
 +
 +
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:
 +
 +
<source lang=bash>
 +
] $ config-pin p1_36 pwm
 +
</source>
 +
 +
After the config-pin utility has been executed change to this directory
 +
 +
<source lang=bash>
 +
] $ cd /sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip0/
 +
</source>
 +
 +
The PB has two PWM chips on board. Chip0 and Chip1. In order to enable Chip0 perform
 +
<source lang=bash>
 +
] $ echo 0 > export
 +
</source>
 +
Now the chip0 is enabled which will reveal a '''pwm0''' directory in current directory.
 +
 +
Change into the directory and list the files available.
 +
 +
<source lang=bash>
 +
[ ✗ 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
 +
</source>
 +
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'''
 +
 +
An example:
 +
<source lang=bash>
 +
[ ✓ root@beaglebone [pwm0] $  echo 1 > enable
 +
[ ✓ root@beaglebone [pwm0] $  echo 1000000000 > period
 +
[ ✓ root@beaglebone [pwm0] $  echo 500000000 > duty_cycle
 +
</source>
 +
The is the result:
 +
 +
[[File:PWM 1 second period 50 percent duty cycle.png|600 px]]

Revision as of 12:18, 9 March 2018

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.

If you are running kernel 3.8.x please follow these guidelines Example One and Example two and the instructions given in Derek Molloys book Exploring BeagleBone Black.

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.

PocketBeagle pinout.png

The IO is available through a virtual filesystem starting in /sys.

Enabling PWM

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

An example:

[ ✓ root@beaglebone [pwm0] $  echo 1 > enable
[ ✓ root@beaglebone [pwm0] $  echo 1000000000 > period 
[ ✓ root@beaglebone [pwm0] $  echo 500000000 > duty_cycle

The is the result:

PWM 1 second period 50 percent duty cycle.png