The prus are there to wiggle pins in any way you want!
The two prus have a combined total of 22 gpio, that can be output, on the beaglebone header, so any of these could be used. Many are not available with the beaglebone black. See the “BeagleBone Capes” section at the circuitco wiki for details.
So, what kind of performance can you get from pru-gpio? The pru just runs a little asm program, so it depends on how few 200MHz clock ticks you can use.
For an example (each line below can be converted to one pru asm instruction):
-
memory address = 0 (1 tick)
-
load pin states from the memory address (2 ticks)
-
set all pin states (1 tick)
-
inc the memory address (1 tick)
-
if the memory address < max address, repeat the loop, goto 2 (1 tick)
-
need to restart pwm cycle, so goto 1 (1 tick)
So, with this, you could load the pru memory with an array of the pru-gpio pin states, and it would repeatedly cycle through them (up to max address states), giving you a pwm signal.
Since there are 5 ticks per pin-state-update loop in the code, and 5ns per tick, that would be 25ns control of the pwm. A 40kHz pwm signal takes 25us to repeat, so that would fit 25us/25ns = 1000 individual pin states, or nearly 10 bits of resolution, for 14 pwm signals (if you used pru1 and disabled hdmi).
The PRU package from ti has an interface that lets you access pru memory as a pointer/array, so the above would just involve updating an array to change any or all of the pwm patterns.
Also can the PRU unit write to any pin? or only some of the pins?
The pru has single tick access to the pru-gpio pins, and something like 3-5 tick (can’t remember exact range I saw) access to all non-privileged system memory. The system memory access varies because the cpu could be doing a read or write at the same time, causing a stall. Since the gpio registers are in non-privileged memory, the pru can be used to toggle regular gpio pins, but going through system memory will be much slower than a pru gpio pin, and put a load on the memory bus.
Please excuse any errors…I’m busy at work. 