Microblaze function with arguments asynchronous from python


For a project I need more PWM outputs than there are available on the RPI IOP microblaze. I made a program which runs softpwm on the microblaze. The exact timing is not very important as it’s just to drive some LEDs.
As stated in the microblaze programming guide, it’s possible to have the microblaze running code asynchronously to the ZYNQ PS. To do that, the c function that runs on the µblaze has to be a void type and cannot have any input arguments. This is where the problem rises: the values such as PWM period and dutycycle have to be passed to make it work. However when i run the function, it blocks the python code as is stated in the documentation. Is there any way around this?
Sadly I have been forbidden to make any changes that would require me to resynthesize the base overlay or i would have just rerouted the PWM IOs from other microblazes to the RPI header.
softpwmtest.ipynb (13.2 KB)

So you should be able to have inputs the function - the only requirement for an asynchronous function is a void return type. Note that there’s no multi-tasking so you can only have one long-running process at once.

In terms of interacting with the microblaze there’s a counter example in the programming notebook which gives a way of doing this. Specifically having your long-running process periodically call yield() which will allow other requests to be serviced. The downside is that you lose determinism with your PWM output but in your case that might not be an issue.

I got it working: in the below mentioned exerpt from the PYNQ readthedocs, we can see that const pointer types are passed between the python and microblaze without return.
My pointer variables can be constant, I declared them in my c code as such and now the code runs as I want it.

this is the exerpt from the PYNQ read the docs

Data Transfer

All return values are passed back to Python through copying. The transfer of function arguments depends on the type used. For a given non-void primitive the following semantics:

  • Non-pointer types are copied from PYNQ to the microblaze
  • Const pointer types are copied from Python to the Microblaze
  • Non-const pointer types are copied from Python to the Microblaze and then copied back after completion of the function.

this requires the function to terminate, but my long running process is made to not terminate.
This means I can’t pass non constant arrays.
So for future reference:
softpwmtest (1).ipynb (3.0 KB)