July 2019 AN5027 Rev 2 1/66
1
AN5027
Application note
Interfacing PDM digital microphones using
STM32 MCUs and MPUs
Introduction
Digital MEMS (microelectromechanical systems) microphones target all audio applications
where small size, high sound quality, reliability and affordability are key requirements.
Their combination of small footprint and noise immunity allows the implementation of
multiple microphones in a single device, creating an increasing growth of audio in industrial
and consumer applications by offering a hands-free human machine interface, noise
cancellation, and high quality audio capture.
The STM32 32-bit Arm
®
Cortex
®
MCUs and the STM32 Arm
®
Cortex
®
MPUs offer a wide
audio capability with a rich connectivity, including serial and enhanced voice-acquisition
interfaces allowing the user to easily build solution for microphone-based applications.
This document targets digital MEMS microphones having a pulse-density modulated (PDM)
output and describe how to connect them in mono and stereo configurations to STM32
MCUs and MPUs by using the SPI/I2S, SAI and DFSDM peripherals. It provides guidelines
and examples based on STM32CubeMX and shows how to properly configure the STM32
device to acquire and handle raw data from the microphones in order to transform this raw
data into standard data for audio.
www.st.com
Contents AN5027
2/66 AN5027 Rev 2
Contents
1 PDM digital microphones overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1 Sound acquisition overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 PDM digital microphone block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Basic digital microphones connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 PDM and PCM signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.1 Pulse density modulation (PDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.2 Pulse code modulation (PCM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.3 PDM to PCM conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5 Acoustic parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5.1 Sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5.2 Signal-to-noise ratio (SNR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5.3 Acoustic overload point (AOP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.5.4 Power supply rejection ratio (PSRR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.6 Added value of digital microphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7 Available ST digital microphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2 Connecting PDM digital microphones to STM32 MCUs and MPUs . . 16
2.1 Serial peripheral interface (SPI) /Inter-IC sound (I2S) . . . . . . . . . . . . . . . 16
2.1.1 Mono configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.2 Stereo configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 Serial audio interface (SAI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.1 Using a single sub-block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.2 Using two synchronous SAI sub-blocks . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.3 Using PDM interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Digital filter for sigma delta modulators (DFSDM) . . . . . . . . . . . . . . . . . . 27
2.3.1 Stereo configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4 Clocking considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4.1 The digital microphone clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4.2 The peripheral clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.5 GPIOs number considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3 Digital signal processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.1 PDM audio software decoding library . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32