PWM Not Controlling Servo on BeagleBone Black

Hello everyone,

I’m currently working with a BeagleBone Black (BBB) to control a servo motor using PWM on pin P9_14, but I’m not getting any response from the servo despite configuring everything according to standard setup procedures. I am using a custom Yocto Kirkstone image built with the “meta-ti” layer and a kernel checked out at branch v6.1.80-ti-r34. Here are the detailed steps I’ve taken and configuration I’ve tried:

1. Hardware Setup

  • I connected the servo’s signal line to P9_14.
  • The servo has been powered through P9_7 (SYS_5V) and P9_2 (DGND) lines.

2. Software and Overlay Setup

  • I created and loaded a custom Device Tree Overlay (DTSO) to enable PWM on pwmchip0 with the this configuration for P9_14.

3. Exporting and Configuring PWM Channel

For P9_14 (pwmchip0, channel 0)

  1. Exported the PWM channel:
echo 0 > /sys/class/pwm/pwmchip0/export
  1. Set period and duty cycle for a 50Hz signal (20ms period):
echo 20000000 > /sys/class/pwm/pwmchip0/pwm0/period  # 20ms
echo 1000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle  # 1ms
  1. Enabled the PWM:
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

4. Testing and Observations

  • I tried gradually adjusting the duty cycle between 1ms and 2ms to test the servo range.
  • Checked the system log with dmesg | tail, but there were no errors or warnings related to PWM.
  • Despite this, the servo did not move.

Request for Assistance

I suspect there may be an issue with my Device Tree Overlay or with how PWM is configured on my BBB. Could someone help verify if my overlay configuration is correct for enabling PWM on this pin? Additionally, if there are other steps or tools I could use to diagnose this issue, I would greatly appreciate any suggestions.

Thank you for your time and assistance!

A couple of thoughts.

I believe the 2 channels on a PWM need to have the same frequency. I have found at times, that only setting the frequency on one channel does not always work. So try setting the period for both channels.

Are you sure the duty cycle is a time period and not a percentage or a 0-255 value ? Trying to write a too large a value may just be treated as 0.

With this sort of thing it is always handy to have a scope handy to check the output of the pins.

I believe the 2 channels on a PWM need to have the same frequency. I have found at times, that only setting the frequency on one channel does not always work. So try setting the period for both channels.

I tried to set both channel to the same frequency (same period and same duty_cycle) but never changes.

Are you sure the duty cycle is a time period and not a percentage or a 0-255 value ? Trying to write a too large a value may just be treated as 0.

I am quite sure as I saw all over the examples , those values are not writed as percents values or in 0-255 values range…

I finally found the right formula!

From the standard DTS here, I just added the following code for enabling P9_14 PWM pin:

&am33xx_pinmux {
  bb_pwm1_pins: pinmux_bb_pwm1_pins {
    pinctrl-single,pins = <
      0x48 0x06  /* P9_14 (U14) gpmc_a2.ehrpwm1A, mux mode 6 */
    >;
  };
};

&epwmss1 {
  status = "okay";
};

&ehrpwm1 {
  status = "okay";
  pinctrl-names = "default";
  pinctrl-0 = <&bb_pwm1_pins>;
};

Now exporting and configuring the PWM Channel like I did in my step #3 works great :smiley:

1 Like