BeagleBone PWM - what is the truth?

Hi,

I’m playing with PWM on BeagleBone. I’m a little bit confused because I can not find clear information about PWM.
First of all, system reference manual says:
“There are up to eight PWM outputs on the expansion header.”
But I could only find 4 PWM, did I miss something?

Using PWM driver I was able to use only ehrpwm.1:0 and ehrpwm.1:1. In pwm device directory I see ehrpwm.0:x files and ecap, so it seems it’s not possible to use driver for ehrpwm2.

Summarizing:

  1. Is it possible to use more than 4 PWM channels?
  2. Is it possible to control ehrpwm2 using pwm driver?

All on Angstrom distro.

Regards,
Michal

Michal,

On the BeBoPr cape I'm using both ehrpwm2 channels, so yes, it is possible to use these channels.
I'm not sure about your other question, maybe someone else can answer that one.

Cheers,
Bas

Some version of the linux kernel do not have all the PWMs enabled.

This SD card image:
<http://dominion.thruhere.net/koen/angstrom/beaglebone/Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.05.31.img.xz>
has all PWMs on my beaglebone.

Cordially,

Thanks guys, but is it possible to use ecap.x & ehrpwm.0:x? I do not see any pin on the P8 or P9.

/*

  • EHRPWM1 :
  • EHRPWM1A : P9.14
  • EHRPWM1B : P9.16
  • EHRPWM2 :
  • EHRPWM2A : p8.19
  • EHRPWM2B : P8.13
    */

static struct pinmux_config ehrpwm1_pin_mux[] = {
{“gpmc_a2.ehrpwm1A”, OMAP_MUX_MODE6 | AM33XX_PIN_OUTPUT},
{“gpmc_a3.ehrpwm1B”, OMAP_MUX_MODE6 | AM33XX_PIN_OUTPUT},
{NULL, 0},
};

static struct pinmux_config ehrpwm2_pin_mux[] = {
{“gpmc_ad8.ehrpwm2A”, OMAP_MUX_MODE4 | AM33XX_PIN_OUTPUT},
{“gpmc_ad9.ehrpwm2B”, OMAP_MUX_MODE4 | AM33XX_PIN_OUTPUT},
{NULL, 0},
};

static void ehrpwm1_init(int emv_id, int profile)
{
setup_pin_mux(ehrpwm1_pin_mux);

am33xx_register_ehrpwm(1, &pwm_pdata[1]);
}

static void ehrpwm2_init(int emv_id, int profile)
{
setup_pin_mux(ehrpwm2_pin_mux);

am33xx_register_ehrpwm(2, &pwm_pdata[2]);
}

Spinobot於 2012年6月20日星期三UTC+8上午4時35分41秒寫道:

Hi, you can get up to 6 PWM outputs, given that you set up your pin
mux in the right way. For a project I'm working on, I'm using the
beaglebone's PWM otuputs to control some RC ESCs. After searching for
a while, all I found was python, javascript and shell script so I've
written a C++ class to access PWM. I just needed C++, not that I have
anything against python or javascript or shell script. I just wrap the
sysfs files. ehrpwm0:0 through ehrpwm2:1. The repository is at
https://github.com/clausqr/beaglebone-cpp-PWM and you can check it
out.
Anyway, you need a kernel which exposes the pwm through sysfs. I'm
running debian with the 3.2.18-psp14 kernel. I'm also covering it at
my blog http://quadrotordiaries.blogspot.com
If you just want to get those extra 2 PWM outputs you gotta 'echo 1 >
mcasp0_aclkx' and 'echo 1 > mcasp0_fsx' into your pin mux or use
sunnycjliu's elegant solution, adding those two pin muxes as EHRPWM0,
and you get them at pins P9.29 and P9.31. You may loose access to TI's
multichannel audio, though.
I think you can get an extra PWM out of the TPS65217 but I wouldn't go that way.
And remember that these PWMs are 3.3v, so if you are driving something
hefty be careful to interface it accordingly...

Hi, which mode do you use for gpmc_ad9 and gpmc_ad8 (ehrpwm2)?
For example, for ehrpwm1 I do ‘echo 6 > /sys/kernel/debug/omap_mux/gpmc_a2’
and for mcasp0_aclkx, as you said, ‘echo 1 > mcasp0_aclkx’ but I am no able
to use ehrpwm2 (pins p8_13 and _p8_19).

I was looking at your code but I can’t find this information.

Thank you

2012/6/22 claus rosito <hola@claus.com.ar>

Hi Álvaro, I'm doing the pin mux configuration outside of the cPWM
class, as it is not a specific property of the PWMSS. It is a property
of the whole board and how it is configured. When it boots up, I have
a script that calls dwatts' setPWMReg.py and configures the pin mux to
my liking.
the script is simple and goes like this (looked up from the bone SRM
pin mux config table):

#configure PWM registers
python setPWMReg.py

#now configure the pin mux
#eHRPWM0A=P9.29
echo 1 > /sys/kernel/debug/omap_mux/mcasp0_fsx
#eHRPWM0B=P9.31
echo 1 > /sys/kernel/debug/omap_mux/mcasp0_aclkx
#eHRPWM1A=P9.14
echo 6 > /sys/kernel/debug/omap_mux/gpmc_a2
#eHRPWM1B=P9.16
echo 6 > /sys/kernel/debug/omap_mux/gpmc_a3
#eHRPWM2A=P8.13
echo 4 > /sys/kernel/debug/omap_mux/gpmc_ad8
#eHRPWM2A=P8.19
echo 4 > /sys/kernel/debug/omap_mux/gpmc_ad9

Thank you!

And I want share something else.
Using ecap you can get more pwm pins. Ecap have some differences, you can check it here http://processors.wiki.ti.com/index.php/AM335x_PWM_Driver%27s_Guide#eCAP

To use this pins just:
pin P9_42
Set mode: echo 0 > /sys/kernel/debug/omap_mux/ecap0_in_pwm0_out
/sys/class/pwm/ecap.0

pin P9_28
echo 4 > /sys/kernel/debug/omap_mux/mcasp0_ahclkr
/sys/class/pwm/ecap.2

The page 26 of the beaglebone SRM rev A5.0.1 says that there are up to 8 PWM pins. But in
/sys/class/pwm there is a directory called ecap.1 that probably is other PWM pin. It could be
the ninth PWM pin? I have not found any reference in the beaglebone SRM

Saludos

2012/6/23 claus rosito <hola@claus.com.ar>

If you just want to get those extra 2 PWM outputs you gotta ‘echo 1 >
mcasp0_aclkx’ and ‘echo 1 > mcasp0_fsx’ into your pin mux or use

Thanks! I must be blind searching mux table. I thought I need to use extra AVR for those 2 PWMs. Now all 6 PWM channels looks nicely on the oscilloscope.

By the way ehrpwm0.0 and ehrpwm0.1 are also available on pins P9.22 (spi0_sclk) and P9.21 (spi0_d0) in mode 3 (as ehrpwm0A and ehrpwm0B).
It’s worth to mention that to use every pair of PWM signals appropriate clock must be activated (CM_PER_EPWMSS1_CLKCTRL, CM_PER_EPWMSS2_CLKCTRL, CM_PER_EPWMSS3_CLKCTRL)

Regards,
Michal

Hi, thanks for the info! Regarding eCAPs, I've checked my
/sys/class/pwm dir and I have the 3 ecaps listed (ecap.0/, ecap.1/,
ecap.2/), with all the properties exposed in each dir. I'm running
3.2.18-psp14. But only ecap0 seems to be routed, the other 2 aren't
exposed. Is anybody using these eCAPs?

To clarify, the am335x has a maximum of 9 PWM outputs:

2x from each ehrpwm instance
1x from each ecap instance (assuming the primary ecap feature is not being used)

however, the beaglebone has 8 available on the expansion headers. The only one not available is ecap1.

But only ecap0 seems to be routed, the other 2 aren’t
exposed. Is anybody using these eCAPs?

ecap2 can be muxed to pin 28 on expansion P9

Hope this helps
Rob