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

From Klaus' wiki
Jump to: navigation, search
Line 9: Line 9:
 
[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.
 
[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]]
+
[[File:PocketBeagle_pinout.png|500px]]
  
 
The IO is available through a virtual filesystem starting in /sys.
 
The IO is available through a virtual filesystem starting in /sys.
Line 15: Line 15:
 
===Enabling PWM===
 
===Enabling PWM===
  
Switch to user root.
+
Switch to user '''root'''.
 
<source lang=bash>
 
<source lang=bash>
 
] $ su -
 
] $ su -
Line 22: Line 22:
 
The utility '''config-pin''' can setup the configuration.  
 
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:
+
The PB has two PWM chips on board. Chip0 and Chip1 each carrying two PWM channels.
 +
 
 +
In order to send pwm output from PWM A from Chip0 through the pinmux to pin 1,36 issue this command:
  
 
<source lang=bash>
 
<source lang=bash>
Line 34: Line 36:
 
</source>
 
</source>
  
The PB has two PWM chips on board. Chip0 and Chip1. In order to enable Chip0 perform
+
In order to enable Chip0 perform
 
<source lang=bash>
 
<source lang=bash>
 
] $ echo 0 > export
 
] $ echo 0 > export
Line 40: Line 42:
 
Now the chip0 is enabled which will reveal a '''pwm0''' directory in current directory.
 
Now the chip0 is enabled which will reveal a '''pwm0''' directory in current directory.
  
Change into the directory and list the files available.
+
Change into the directory '''pwm0''' and list the files available.
  
 
<source lang=bash>
 
<source lang=bash>
Line 57: Line 59:
 
provided you've made an alias called ll in root home directory in the file .bashrc - otherwise use ls -al
 
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 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 period time for the pwm signal into '''period'''
Line 72: Line 74:
  
 
[[File:PWM 1 second period 50 percent duty cycle.png|600 px]]
 
[[File:PWM 1 second period 50 percent duty cycle.png|600 px]]
 +
 +
Of course the enabling can happen at anytime desireable, so you can setup the polarity, period and duty cycle when ever convinient and enable when needed. Writing a 0 into '''enable''' disables the output again.

Revision as of 12:28, 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.

The PB has two PWM chips on board. Chip0 and Chip1 each carrying two PWM channels.

In order to send pwm output from PWM A from Chip0 through the pinmux to pin 1,36 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/

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 pwm0 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

Of course the enabling can happen at anytime desireable, so you can setup the polarity, period and duty cycle when ever convinient and enable when needed. Writing a 0 into enable disables the output again.