Use PWM and UART at the same time

321 views
Skip to first unread message

Theodosis Ntegiannakis

unread,
Nov 6, 2016, 6:26:59 PM11/6/16
to BeagleBoard
Hello,

I am developing a ROS project and I am using Ubuntu 16.04.1 on Beaglebone Black with 4.4.23-ti-r51 kernel.
I have a setup which uses the following pins:

Analog: P9_40, P9_39, P9_38, P9_37, P9_36
PWM: P9_16, P8_13
UART2, UART4 ,
GPIO: P9_41

In /boot/uEnv.txt I only have the line cape_universal=enable

and in /etc/default/capemgr
CAPE=cape-universaln

as a result cat /sys/devices/platform/bone_capemgr/slots command reports:
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universaln

I am using Adafruit_BBIO library to control PWM and ADC and UART.

With the above settings ADC and PWM works fine, but not UART...
Although /dev/ttyO2 and /dev/ttyO4 are present it doesn't work.

If I, on the other hand, if I add on /boot/uEnc.txt the following
cape_enable=bone_capemgr.enable_partno=BB-UART2,BB-UART4,BB-PWM1,BB-PWM2

Then UART ports are fine, but PWM has the following error.
Traceback (most recent call last):
  File "/home/ubuntu/catkin_ws/src/robot_core/scripts/wheel_controller.py", line 17, in <module>
    PWM.start(LEFT_MOTOR_PIN, PWM_DUTY_CYCLE, PWM_NEUTRAL_FREQUENCY, 1)
RuntimeError: Problem with the cape manager


I am having trouble understanding dts files in order to create my own overlay.
Also when i tried to run config-pin i get command not found
and with sudo sh -c "echo 'BB-UART2' > /sys/devices/platform/bone_capemgr/slots" i get sh: echo: I/O-error

i am a bit confused!

Charles Steinkuehler

unread,
Nov 7, 2016, 8:29:07 AM11/7/16
to beagl...@googlegroups.com
On 11/6/2016 4:46 PM, Theodosis Ntegiannakis wrote:
>
> With the above settings ADC and PWM works fine, but not UART...
> Although /dev/ttyO2 and /dev/ttyO4 are present it doesn't work.

You have to set the pins to the proper pinmux values for UART and PWM,
not just load the overlay.

> I am having trouble understanding dts files in order to create my own overlay.
> Also when i tried to run config-pin i get command not found

You are running a non-standard distribution. The universal overlays
are part of the BBB kernels, but the config-pin utility is probably
not getting installed. Just grab it from github:

https://github.com/cdsteinkuehler/beaglebone-universal-io

...or you can directly play with the sysfs entries created by the overlay.

> and with sudo sh -c "echo 'BB-UART2' > /sys/devices/platform/bone_capemgr/slots"
> i get sh: echo: I/O-error

This generally means the cape couldn't be loaded. You can sometimes
find more detail at the end of dmesg output, but failures when trying
to load capes are usually pretty cryptic.

--
Charles Steinkuehler
cha...@steinkuehler.net

William Hermans

unread,
Nov 7, 2016, 2:19:58 PM11/7/16
to beagl...@googlegroups.com
> and with sudo sh -c "echo 'BB-UART2' > /sys/devices/platform/bone_capemgr/slots"
> i get sh: echo: I/O-error

This generally means the cape couldn't be loaded.  You can sometimes
find more detail at the end of dmesg output, but failures when trying
to load capes are usually pretty cryptic.

I've seen this happen several time when loading a cape, that is trying to configure pins that have already been configured. For me, this happened after unloading the previous cape. There still seems to be a "bug" when unloading capes.


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/db971a2d-a086-ddc1-2d15-bbfd9958ff77%40steinkuehler.net.
For more options, visit https://groups.google.com/d/optout.

Theodosis Ntegiannakis

unread,
Nov 7, 2016, 3:38:43 PM11/7/16
to BeagleBoard


On Monday, November 7, 2016 at 3:29:07 PM UTC+2, Charles Steinkuehler wrote:
You have to set the pins to the proper pinmux values for UART and PWM,
not just load the overlay.

How do you suggest i should enable all the pins needed?
If i try to enable BB-PWM0,1,2 overlays pwm still doesn't work from Adafruit_BBIO library...


You are running a non-standard distribution.  The universal overlays
are part of the BBB kernels, but the config-pin utility is probably
not getting installed.  Just grab it from github:

https://github.com/cdsteinkuehler/beaglebone-universal-io

...or you can directly play with the sysfs entries created by the overlay.

I will try this also...
I hope i will eventually find out how.  

Theodosis Ntegiannakis

unread,
Nov 7, 2016, 3:39:52 PM11/7/16
to BeagleBoard


On Monday, November 7, 2016 at 9:19:58 PM UTC+2, William Hermans wrote:
> and with sudo sh -c "echo 'BB-UART2' > /sys/devices/platform/bone_capemgr/slots"
> i get sh: echo: I/O-error

This generally means the cape couldn't be loaded.  You can sometimes
find more detail at the end of dmesg output, but failures when trying
to load capes are usually pretty cryptic.

I've seen this happen several time when loading a cape, that is trying to configure pins that have already been configured. For me, this happened after unloading the previous cape. There still seems to be a "bug" when unloading capes.


Should i report this "bug" somewhere?

William Hermans

unread,
Nov 7, 2016, 4:18:09 PM11/7/16
to beagl...@googlegroups.com
No, I think it's a known issue already.

Charles Steinkuehler

unread,
Nov 7, 2016, 4:19:47 PM11/7/16
to beagl...@googlegroups.com
On 11/7/2016 2:38 PM, Theodosis Ntegiannakis wrote:
>
> On Monday, November 7, 2016 at 3:29:07 PM UTC+2, Charles Steinkuehler wrote:
>
> You have to set the pins to the proper pinmux values for UART and PWM,
> not just load the overlay.
>
> How do you suggest i should enable all the pins needed?
> If i try to enable BB-PWM0,1,2 overlays pwm still doesn't work from
> Adafruit_BBIO library...

Use the universal overlay. I created it specifically because it is
difficult or impossible to load several of the individual overlays for
various functions (like PWM and UART) because they conflict.

...or craft your own custom overlay with exactly what you want, but
that is a fairly high barrier to entry for most users. The universal
overlay allows selecting specific pin functions on a per-pin basis,
while enabling most of the commonly used special hardware features.

--
Charles Steinkuehler
cha...@steinkuehler.net

William Hermans

unread,
Nov 7, 2016, 4:19:52 PM11/7/16
to beagl...@googlegroups.com
So if this continues to be a problem for you. Once you unload a cape, you should instead just reboot. This is not ideal, but it's what we have right now . . .

William Hermans

unread,
Nov 7, 2016, 4:26:04 PM11/7/16
to beagl...@googlegroups.com
What I did was take a couple of Charles' universal IO capes, and strip out what I did not need, then combine what I needed into two files. So, I have all 3 "dual channel" PWMs, and UART4 working in the same file.

So like if a pin had the ability to be muxed 5, or 6 different ways. I only left the one I needed, then changed that one to "default" for the pinmux naming. Do also keep in mind I did not get this right the first time, I had to experiment a few times. . . . So you should experiment youself( Theodosis ) to get a better understanding of what's going on.

Theodosis Ntegiannakis

unread,
Nov 7, 2016, 5:56:59 PM11/7/16
to BeagleBoard
I tried twice to implement my own overlay but I gave up because I had a significant lack of knowledge at this point.

Finally i used cape-universala (in which pwm works fine) and enabled uart2 and uart4 pins by using config-pin.
Now it works! (hope nothing else has broken!)

Thank you very much!


one last question:
pins enabled using config-pin command are enabled until reboot.

how can i keep these pins after reboot?

William Hermans

unread,
Nov 7, 2016, 6:25:21 PM11/7/16
to beagl...@googlegroups.com
On Mon, Nov 7, 2016 at 3:56 PM, Theodosis Ntegiannakis <tntegi...@gmail.com> wrote:
I tried twice to implement my own overlay but I gave up because I had a significant lack of knowledge at this point.

Finally i used cape-universala (in which pwm works fine) and enabled uart2 and uart4 pins by using config-pin.
Now it works! (hope nothing else has broken!)

Thank you very much!


one last question:
pins enabled using config-pin command are enabled until reboot.

how can i keep these pins after reboot?


You create a systemd service, or use rc.local, and put the "commands" in there. Which will be applied at boot.

Theodosis Ntegiannakis

unread,
Nov 8, 2016, 1:40:52 PM11/8/16
to BeagleBoard
Thank you again!

Alexand...@gmx.de

unread,
May 3, 2017, 5:47:34 PM5/3/17
to BeagleBoard
Theodosis, did you get it to work?
I have a small test.sh file containing 
#!/bin/bash
config
-pin P9.11 uart

I tried both, systemd and rc.local, but in both cases i get "P9_xx pinmux file not found".
If I run the script after logging in everything works fine.
Reply all
Reply to author
Forward
0 new messages