PDM support on Micropython

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
CharlesFr
Posts: 6
Joined: Mon Oct 22, 2018 6:16 pm

PDM support on Micropython

Post by CharlesFr » Thu Mar 19, 2020 4:52 pm

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 ?

User avatar
jimmo
Posts: 2346
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: PDM support on Micropython

Post by jimmo » Fri Mar 20, 2020 2:44 am

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.

njepsen
Posts: 4
Joined: Tue Jun 22, 2021 4:08 am
Location: New Zealand.

Re: PDM support on Micropython

Post by njepsen » Tue Jun 22, 2021 4:21 am

is there any support for this yet?

User avatar
Mike Teachman
Posts: 101
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: PDM support on Micropython

Post by Mike Teachman » Sat Jun 26, 2021 10:41 pm

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

njepsen
Posts: 4
Joined: Tue Jun 22, 2021 4:08 am
Location: New Zealand.

Re: PDM support on Micropython

Post by njepsen » Wed Jul 21, 2021 10:28 pm

Thanks for your reply Mike.
neil

User avatar
jimmo
Posts: 2346
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: PDM support on Micropython

Post by jimmo » Wed Jul 21, 2021 11:50 pm

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)

User avatar
mattyt
Posts: 367
Joined: Mon Jan 23, 2017 6:39 am

Re: PDM support on Micropython

Post by mattyt » Wed Jul 21, 2021 11:59 pm

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.

Post Reply