pwm from pru on beaglebone black

Hi @dotbit!

Q1: It’s hard to get all system components installed and running for libpruio. Perhaps you want to test on a proven system first, and do all the config hassle when you’re sure it meeds your need.

You may want to check out the pre-installed SD image at libpruio - pre-installed on 5.10 kernel image. After booting from the burned SD card, the library and all examples are pre-installed, ready to test.

Q2: The main programm is running on ARM and loads (and starts) the PRU firmware. In libpruio, calling the constructor loads and starts the firmware on the configured PRU. Afterwards on the other PRU, a second firmware can get loaded by function load_firmware and started by function prussdrv_pru_enable.

See examples pruss_add or pruss_toggle.

Q3: Modes mm and rb are related to ADC. Yes, io mode seems to be fine.

It seems to be a good idea to watch rotation/position. The prefered solution should be a QEP sensor.

When using hardware PWM, you may consider to generate an interrupt on each PWM cycle, counting impulses. This is a small callback in the PRU firmware, but needs some configuration for the interupt controller.

In contrast, you can generate the PWM pulses in the PRU firmware. Check direct GPIO for output (fixed three cycle latency). Anyway, this also needs some loopback for pulse counting/checking.

Regards

PS: Regarding timing, 200 PRU cycles (enough for your main loop) is 1 μs (0.001 ms). You should be fine.