Page 1 of 1

PDM support on Micropython

Posted: Thu Mar 19, 2020 4:52 pm
by CharlesFr
Hi,

I would like to know if there is a PDM support for my Micropython Board ?
It's for MEMS Microphone.

Someone can help me ?

Re: PDM support on Micropython

Posted: Fri Mar 20, 2020 2:44 am
by jimmo
I took a quick look out of curiosity.

On STM32, some of the newer families (L4, H7, possibly others) have a DFSDM peripheral -- so you do the whole thing in hardware and just get a PCM stream out of it. (This peripheral is not currently supported in MicroPython... you could try and poke the registers directly, but it involves setting up DMA etc...not easy)

But PDM is synchronous serial, so if you're prepared to do the delta-sigma demodulation (i.e. pulse density) yourself, then you can read data from it directly using SPI (or I2S). It's just not going to be possible to get continuous audio without again doing DMA etc as you'll be alternating between requesting SPI data then processing it. DMA is definitely on the TODO list for MicroPython's SPI driver but not currently supported.

Re: PDM support on Micropython

Posted: Tue Jun 22, 2021 4:21 am
by njepsen
is there any support for this yet?

Re: PDM support on Micropython

Posted: Sat Jun 26, 2021 10:41 pm
by Mike Teachman
If you would consider an I2S MEMS microphone you could look at integrating this PR into a custom build. It supports the PyBoard.
https://github.com/micropython/micropython/pull/7183

Or, try out the I2S feature with a pre-built binary, available here:
https://github.com/miketeachman/micropy ... s-examples

Re: PDM support on Micropython

Posted: Wed Jul 21, 2021 10:28 pm
by njepsen
Thanks for your reply Mike.
neil

Re: PDM support on Micropython

Posted: Wed Jul 21, 2021 11:50 pm
by jimmo
njepsen wrote:
Wed Jul 21, 2021 10:28 pm
Thanks for your reply Mike.
FYI Mike's PR was merged and the I2S functionality is now available in the nightly builds (and will be in 1.17)

Re: PDM support on Micropython

Posted: Wed Jul 21, 2021 11:59 pm
by mattyt
7183 was merged a couple of weeks ago - congrats and thanks Mike! - so the ESP32 and STM32 daily ('unstable') builds should also have I2S.

Documentation has also been published: I2S library docs and the I2S entries in the QuickRef for ESP32 and STM32.