--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/dkS51WbicTo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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!
0x024 0x4 corresponds to ehrpwm2B = P8_13
0x020 0x4 corresponds to ehrpwm2A = P8_19
0x150 0x3 corresponds to ehrpwm0A = P9_14
(Are we missing some pins)
Also, how do you know it's pin 0 to export? I thought this were more like exporting GPIO, whereas you'd need to know which pin is which to export?
Thanks,
Khanh