On Wednesday, 30 September 2015 21:55:42 UTC-4, [email protected] wrote: > > I am using the ehrpwm2A PWM on P8_19. Usage of this requires the following > device tree overlay (BB-PWM2-00A0.dts): > > > /dts-v1/; > > /plugin/; > > > /{ > > compatible = "ti,beaglebone", "ti,beaglebone-black"; > > part-number = "BB-PWM2"; > > version = "00A0"; > > > fragment@0 { > > target = <&am33xx_pinmux>; > > __overlay__ { > > pinctrl_spec: Panel_Pins { > > pinctrl-single,pins = < > > 0x020 0x04 /* P8_19 MODE4 ehrpwm2A PWM */ > > >; > > }; > > }; > > }; > > > fragment@1 { > > target = <&ocp>; > > __overlay__ { > > test_helper: helper { > > compatible = "bone-pinmux-helper"; > > pinctrl-names = "default"; > > pinctrl-0 = <&pinctrl_spec>; > > status = "okay"; > > }; > > }; > > }; > > > fragment@2 { > > target = <&epwmss2>; > > __overlay__ { > > status = "okay"; > > }; > > }; > > > fragment@3 { > > target = <&ehrpwm2>; > > __overlay__ { > > status = "okay"; > > }; > > }; > > > }; > > > In the above device tree overlay, fragment 0 configures P8_19 to be the > output of PWM2A (instead of a GPIO or other function), and fragments 1, 2, > and 3 enable the needed on-chip peripherals. 'ocp' is on-chip-peripherals, > 'epwmss' is PWM sub-system, and 'ehrpwm2' is PWM2. > > > Compile this overlay using: > > > dtc -O dtb -o BB-PWM2-00A0.dtbo -b 0 -@ BB-PWM2-00A0.dts > > > Copy to /lib/firmware: > > > sudo cp BB-PWM2-00A0.dtbo /lib/firmware > > > At this point, get to root: > > > sudo su > > > Load the device tree overlay (this must be done logged in as root, sudo > won't work – I think because of the redirect). Note that this path is > different than the earlier kernels due to a redesign of the cape manager: > > > root@arm:/home/ubuntu# echo BB-PWM > > /sys/devices/platform/bone_capemgr/slots > > > Check that overlay was loaded: > > > root@arm:/home/ubuntu# cat /sys/devices/platform/bone_capemgr/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-PWM2 > > > Check that the pin is configured to output the PWM2A: > > > root@arm:/home/ubuntu# cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins > | grep 0820 > > > pin 8 (44e10820.0) 00000004 pinctrl-single > > > You need to see the pinmux at offset $820 have mode 4. If it is not 4, > your PWM may be working fine, but you won't see the signal on pin P8_19. > > > You should also see pwmchip0 appear at /sys/class/pwm: > > > root@arm:/home/ubuntu# ls /sys/class/pwm > > pwmchip0 > > > Change to pwmchip0 folder: > > > root@arm:/home/ubuntu# cd /sys/class/pwm/pwmchip0 > > > Export the PWM to userspace: > > > root@arm:/sys/class/pwm/pwmchip0# echo 0 > export > > > You should now see a pwm0 folder: > > > root@arm:/sys/class/pwm/pwmchip0# ls > > device export npwm power pwm0 subsystem uevent unexport > > > Change to the pwm0 folder, configure the PWM and enable it: > > > root@arm:/sys/class/pwm/pwmchip0/pwm0# ls > > duty_cycle enable period polarity power uevent > > root@arm:/sys/class/pwm/pwmchip0/pwm0# echo 1000000 > period > > root@arm:/sys/class/pwm/pwmchip0/pwm0# echo 250000 > duty_cycle > > root@arm:/sys/class/pwm/pwmchip0/pwm0# echo 1 > enable > > > I think the units of period and duty_cycle are both nanoseconds (not > confirmed with a scope). duty_cycle is not a percentage, so these setting > are running the PWM at 1kHz, 25% duty cycle. > > > Hope this helps! > > Hello again,
After a few hours of tinkering it works! Note that upon doing this im using *kernel 4.1.10-ti-r21 #1*. The main issue here is the version of the device tree compiler you are using. I took as an exemple the device tree structure above (that you did) and tried to compile and load it into the beaglebone with DTC version 1.4.0 and this did not work. Looking around on the glorious internet, I found a post saying that I should try using https://github.com/beagleboard/bb.org-overlays (only up to step 2) After compiling the above structure and copying it to the exact same location as above and executing the echo BB-PWM2 > /sys/devices/platform/bone_capemgr/slots with root privileges i was able to see the pwmchip0 and export the pwm module created from the structure! Thanks again for this! :) +Erik i confirmed that this works on P8_19. Tested with a voltmeter. @ 750000 duty and 250000 to make sure. -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
