hatchjaw I think the instruction to echo MY-PWM-01 > $SLOTS suggests this example predates Bela image 0.3.4 (I'm running 0.3.7d), so instead I had the following in uEnv.txt:
right, the capemgr that allowed that is no longer on the kernel I think.
hatchjaw However the inclusion of the example's .dtbo file appeared to prevent Bela from booting.
That's probably in a too old format, remove that. You don't actually need it, because cape universala should already initialise all the peripherals (I think).
hatchjaw ...but I can't create the pwm3 directory:
the sysfs interface has changed since.
On BelaMini (without the need to load cape universala) I have:
# ls /sys/class/pwm/
pwmchip0 pwmchip2 pwmchip4
with each folder representing a different PWM subsystem. I remember there being a lot of confusion in the way Linux's PWM numbers map to the datasheet's ones and to the BeagleBone documentation ones ... anyhow these three are probably the ones that are broken out on BelaMini (PWM0, PWM1 and PWM2 in BeagleBoard parlance)... In each folder, there is an export file. IIRC, you can use echo 0 > export to export PWM channel "A", which then creates folder pwm-X:0 (where X is the subsystem) and echo 1 > export for channel "B" (pwm-X:1). Getting into these folders you then have the duty_cycle, period and enable files to which you should be able to write via echo, again.
P9_14 is "EHRPWM1A" according to BeagleBoard. A wild guess would be that that is pwmchip2 - channel 0.
Try playing around with something like this
echo 0 > /sys/class/pwm/pwmchip2/export
cd /sys/class/pwm/pwmchip2/pwm-2\:0/
echo 500 > duty_cycle
echo 1000 > period
echo 1 > enable
I also remember there being some weird things in the order duty_cycle and period had to be written for the thing to work ...
hatchjaw Is there a way to set PWM period/duty cycle in C++ instead?
I don't think there is a user-space library provided. You'd have to essentially do the above but opening and writing files from C++. Have a look at https://github.com/BelaPlatform/Bela/blob/master/core/GPIOcontrol.cpp for an example of how that can be done for a similar interface (the sysfs interface for GPIO).
If you need fast, efficient and real-time safe change of the period and duty cycle, you could probably hack your way into it by using sysfs as above for set up and then mapping the peripheral's registers into memory and access them with a simple memory write at runtime. See https://github.com/BelaPlatform/Bela/blob/master/core/Gpio.cpp and https://github.com/BelaPlatform/Bela/blob/master/include/Gpio.h for an example of how that can be done for GPIO.