GitJer / Some_RPI-Pico_stuff

Some experiments I did with the Raspberry Pi Pico

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiple instances of pwmin?

grandaspanna opened this issue · comments

I'm brand new to PIO, but got an example working with this .pio

I have a requirement to measure multiple pwm pins in parallel. Creating a new instance of the class looks to work, but they appear to run sequentially. For testing purposes, I've fed the same signal to two different pins and for a stable waveform, they give the same value.

However, if the waveform slews, I get different readings from each, appearing to show a decent lag. It appears that a read is blocking. Is it possible to make them non-blocking? Or, can they run in different state machines or the other PIO? In my case, I'd like 4 running in parallel. I have alternate code using edge interrupts that seems to work ok, but using the PIO capability seemed ideal.

Sorry for the newbieness if I've bungled terminology here.

You are absolutely right. For a project on a RC plane I had to read more than one PWM signal. After some tinkering I decide to use the SBUS protocol, see here. Anyway, during that tinkering I made a version that can read 4 PWM signals using IRQs and 4 state machines. I have uploaded that new code in the directory PwmIn_4pins in the PwmIn directory.

Hope this helps!

That's awesome - I'll give that a crack. And yes, my use case is RC-related, but needs to be more generic than SBUS ;-)