Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Between 7.1.1 and 7.2.0, a change was made to PDMIn that caused the passed-in sample rate to be used, instead of the fixed value 44100. When the sample rate 16000 was actually used, an underlying problem was exposed: The PIO clock was determined incorrectly.
Some problems in the same area were also resolved: The PIO frequency check was also wrong by a factor of two, and when a too-low sample rate led to the exception being thrown, the incomplete PDMIn object was not correctly deallocated, leading to an error that the pin objects were still in use.
After this change, I get plausible RMS noise level values changing from under 200 in a "quiet room" and up to 6000+ when I make noise directly next to the mic.
I did my testing on a Metro RP2350 with the adafruit PDM mic board, using pins 22 and 23 at a specified frequency of 16000. I also used my scope and checked that a sample rate of 16000 actually gives a PDM "CLK" frequency of 64*16kHz (1.024MHz) after the change, and that significantly smaller sample rate values such as 8000 are correctly rejected and can be tried again without resetting.
Closes: #10799