PWM: changing Period of EHRPWM

Hello,

you can change period by changing dtbo files.

1 Generate dts file from original dtbo file

dtc -I dtb -O dts -o /lib/firmware/bone_pwm_P8_13-00A0.dts /lib/firmware/bone_pwm_P8_13-00A0.dtbo

2 Change period
open file “/lib/firmware/bone_pwm_P8_13-00A0.dts” with editor at lines around line 26:

`

pwm_test_P8_13 {

compatible = “pwm_test”;
pwms = <0xdeadbeef 0x1 0x7a120 0x1>;
`

and change to following, for example change period to 100000ns=0.1ms

`

pwm_test_P8_13 {

compatible = “pwm_test”;
pwms = <0xdeadbeef 0x1 100000 0x1>;
`

where
-3rd parameter of line"pwms = ~" is period.
-period (and other parameters) can be written in either decimal or hexadecimal of 0xABC format.
-default period 0x7a120 is 5000000 in decimal.
-As you mentioned, Both A and B output for one eHRPWM must have same period setting.
If not, the second device will fail to setup at “echo (device)> /sys/devices/bone_capemgr.*/slots” command.

3 Compile to new dtbo file

dtc -O dtb -o bone_pwm_P8_13-00A0.dtbo -b 0 -@ bone_pwm_P8_13-00A0.dts

You’d better back up original dtbo file before overwriting it.

4 Use new dtbo file.

`
echo bone_pwm_P8_13 > /sys/devices/bone_capemgr.*/slots

`

2013年6月4日火曜日 16時33分00秒 UTC+9 sultanof.ilo...@gmail.com:

Thanks,

Tried your trick… even replaced the new dtbo file… but even after that I am getting the default value for Period ( ie, 5000000) and duty (ie, 0) … Is there any step that you missed in between…??. Anyways thanks for the tip…:slight_smile:

Hi,

the problem is a bug in pwm_test so that once you enabled two channels of the same ehrpwm you cannot change the period.

Try look at

http://saadahmad.ca/using-pwm-on-the-beaglebone-black/

https://github.com/SaadAhmad/beaglebone-black-cpp-PWM

I also tried this and had no luck :-/

PWM on the BBB is turning out to be more work than I had thought.

Hi,

In case someone still needs a solution to this problem, I’ve written a small kernel patch: ti_ehr_pwm.patch and a short description of how to apply it: https://randomlinuxhacks.wordpress.com/2014/09/16/changing-pwm-period-on-beaglebone-black/

So far it works for me.