0
\$\begingroup\$

I would like to control a servo motor using PWM. I have loaded the following .dtbo's in the slots in bone_capmgr directory as shown below:

root@beaglebone:/sys/devices/platform/bone_capemgr# cat slots
0: PF----  -1 
1: PF----  -1 
2: PF----  -1 
3: PF----  -1 
4: P-O-L-   0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1
5: P-O-L-   1 Override Board Name,00A0,Override Manuf,am33xx_pwm
7: P-O-L-   2 Override Board Name,00A0,Override Manuf,bspwm_P9_22_3

For PWM, I have successfully loaded pin P9_22 configured as output with mode3 as ehrpwm0A.

Now how do I identify which pwm device is active from the four pwmchips as shown below?

root@beaglebone:/sys/class/pwm# ls
pwmchip0  pwmchip2  pwmchip4  pwmchip5  pwmchip6

I am using BeagleBone Black with the following version:

root@beaglebone:~# uname -a
Linux beaglebone 4.1.18-ti-r53 #1 SMP Thu Mar 17 19:41:05 UTC 2016 armv7l    GNU/Linux

I generated the .dts using the dts generator found HERE. Below is the .dts I used:

 /dts-v1/;
 /plugin/;

 / {
     compatible = "ti,beaglebone", "ti,beaglebone-black";

/* identification */
part-number = "BS_PWM_P9_22_0x3";

/* state the resources this cape uses */
exclusive-use =
    /* the pin header uses */
    "P9.22",
    /* the hardware IP uses */
    "ehrpwm0A";

fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
        bs_pwm_P9_22_0x3: pinmux_bs_pwm_P9_22_0x3 {
            pinctrl-single,pins = <0x150 0x3>;
        };
    };
};

fragment@1 {
    target = <&ocp>;
    __overlay__ {
        bs_pwm_test_P9_22 {
            compatible  = "pwm_test";
            pwms        = <&ehrpwm0 0 500000 0>;
            pwm-names   = "PWM_P9_22";

            pinctrl-names   = "default";
            pinctrl-0   = <&bs_pwm_P9_22_0x3>;

            enabled     = <1>;
            duty        = <0>;
            status      = "okay";
        };
    };
};
};
\$\endgroup\$
  • \$\begingroup\$ Can you post the .dts file that your .dtbo was generated from? You mention configuring the pin, but you didn't mention how you configured the PWM module. I suspect that one, some or all of those "pwmchip?" names are defined in the .dts file. (You can also reverse-compile the .dtbo with the device-tree compiler if you don't have the .dts, but I don't know whether that will give you the names). \$\endgroup\$ – Mark Jun 18 '16 at 5:12
  • \$\begingroup\$ I have configured to use the mode 3 that is ehrpwm0A module. I have updated my question with the .dts. I believe each of those pwmchips has two pwm modules within them as pwm0 and pwm1. Not sure though. \$\endgroup\$ – PsychedGuy Jun 18 '16 at 5:26
  • \$\begingroup\$ Yes, there are three eHRPWM modules in the BBB, and each on has two PWM outputs. You are using the first output of the first module, so I suspect that it is "pwmchip0", but I haven't looked at your .dts file yet. \$\endgroup\$ – Mark Jun 18 '16 at 5:35
  • \$\begingroup\$ OK, those name are not defined in your .dts, so maybe they are defined in "am33xx_pwm"? I'm also wondering what happened to "pwmchip1"? At this point, I would resort to trial-and-error (I've done more than my share of that with with device trees). \$\endgroup\$ – Mark Jun 18 '16 at 5:42
  • \$\begingroup\$ Yes will do that. And after you pointed out, even I am wondering where is pwmchip1?. Will take a peep into the am3xx .dts file. \$\endgroup\$ – PsychedGuy Jun 18 '16 at 6:09
1
\$\begingroup\$

I got the ehrpwm2A PWM on P8_19 working for the current 4.1 kernel. I followed the solution posted by Kevin on google groups Here. Tested and works:). Note that while compiling the .dts on 4.1 Kernel, please use the new version of dtc i.e. DTC 1.4.1. You can upgrade to the new DTC version using Robert Nelsons BB-Overlays, even this one has been explained in the thread. Also some light has been shed on how to check which pwm device is active in this thread.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.