FREQ measurement and PWM to PIO

@phdussud submitted patches that increase the accuracy and range of frequency measurement. Additionally there is a patch to move from the RP2040 PWM hardware to PIO for frequency generation (PWM).

These changes are in the test branch build. Any feedback is greatly appreciated.

Once concern I have is fall-over to PWM/FREQ hardware if no PIO state machines are available. The RP2040 has 2 PIOs with 4 state machines each. Each PIO is limited to 32 total shared instructions. The LEDs use one SM, and now most modes use 1 or 2 SM for IO. I2C uses a bunch of the shared instructions. There are situations where we may have no more than 5 available SM, and maybe 10-16 free instructions. Needing all of that at once is extreme! I Imagine someone will find a way though :slight_smile:

I will look into this more when my family’s visit is over in a few days.

1 Like

I guess the PWM is done in a way that you set a PWM value on the CLI and this is then constantly pulsed out until you change it.

Would it be possible to stream a set of PWM values from the NAND flash out instead? I guess DMA should allow this without too much load on the cores.

Usecase would be for example to filter the output with a small RC filter and then to build a simple DAC out ouf this that then plays some precomputed voltage ramp or similar.

What you say makes sense, but it belongs to a different topic: producing signals.
This topic is about measuring the frequency and duty cycle of an incoming signal

I have actually done an AWG with a resistor ladder, its somewhere around the forum. I like the idea.