UM1901
User manual
Getting started with the software package for digital MEMS
microphones in X-CUBE-MEMSMIC1 expansion for STM32Cube
Introduction
This document describes how to get started with the X-CUBE-MEMSMIC1 software.
X-CUBE-MEMSMIC1 provides the complete STM32 middleware to build applications using
digital MEMS microphones. It is easily ported across different MCU families, thanks to
STM32Cube. This package contains sample applications for the acquisition of PDM signals
from up to four digital MEMS microphones, PDM to PCM conversion and real time
streaming of audio data to a PC via a standard USB audio-input driver.
The software provides implementation examples for STM32 Nucleo platforms equipped with
the X-NUCLEO-CCA02M1 expansion board, featuring two on-board MEMS microphones
(MP34DT01-M) as well as headers to connect additional microphones using ST coupon-
based MEMS microphone boards [4].
The software is based on STM32Cube technology and expands the STM32Cube-based
range of solutions.
June 2015
DocID027906 Rev 1
1/24
www.st.com
24
Contents
Contents
UM1901
1
2
3
STM32Cube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
STM32Cube overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1
1.2
STM32Cube architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
X-CUBE-MEMSMIC1 software expansion for STM32Cube . . . . . . . . . . 6
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1
2.2
2.3
2.4
2.5
2.6
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Sample application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5.1
Hardware-related acquisition processes . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5.2
Application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
PC audio recording utility example: audacity . . . . . . . . . . . . . . . . . . . . . . 10
System setup guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1
3.1.1
STM32 Nucleo platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1.2
X-NUCLEO-CCA02M1 expansion board . . . . . . . . . . . . . . . . . . . . . . . . 12
Software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2
3.3
Hardware and software setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3.1
3.3.2
External microphone connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3.3
Jumper configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Board power supply jumper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
USB connection solder bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3.4
Software setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Development tool-chains and compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Recognition of the device as a standard USB microphone
in Windows 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.5
System setup guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
STM32 Nucleo and microphone expansion board setup . . . . . . . . . . . . . . . . . . . . 20
4
Acronyms and abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2/24
DocID027906 Rev 1
UM1901
5
6
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Contents
DocID027906 Rev 1
3/24
24
STM32Cube
UM1901
1
1.1
STM32Cube
STM32Cube overview
The STMCube™ initiative was designed by STMicroelectronics to help developers reduce
development effort, time and cost. STM32Cube covers the entire STM32 portfolio. Version
1.x includes:
•
•
STM32CubeMX, a GUI for generating C initialization code
a comprehensive embedded software platform for each series (e.g., STM32CubeF4 for
the STM32F4 series):
–
the STM32Cube HAL: STM32 abstraction layer embedded software for maximum
portability across the STM32 portfolio
a consistent set of middleware components such as RTOS, USB, TCP/IP and
graphics
all embedded software utilities with a full set of examples
–
–
Detailed information regarding STM32Cube is available on st.com at
http://www.st.com/stm32cube.
1.2
STM32Cube architecture
The STM32Cube firmware is built around three independent levels that can easily interact
with each other, as shown in the figure below.
Figure 1. Firmware architecture
4/24
DocID027906 Rev 1
UM1901
STM32Cube
Level 0 is divided into three sub-layers:
•
Board support package (BSP): offers a set of APIs for the hardware components on
the hardware boards (audio codec, IO expander, touchscreen, SRAM driver, LCD
drivers, etc.) and consists of two parts:
–
component: the driver relative to the external device on the board and not related
to the STM32, the component driver provides specific APIs to the BSP driver
external components and may be ported to any other board
BSP driver: links the component driver to a specific board and provides a set of
user-friendly APIs named BSP_FUNCT_Action() (e.g., BSP_LED_Init(),
BSP_LED_On(), etc.)
–
It is based on modular architecture, which is easily ported to any hardware by simply
implementing the low level routines.
Hardware Abstraction Layer (HAL): this layer provides the low level drivers and the
hardware interfacing methods to interact with the upper layers (application, libraries
and stacks).
It provides generic, multi-instance and function-oriented APIs which render user
applications unnecessary by providing ready to use processes. For example, for the
communication peripherals (I²S, UART, et.), it provides APIs to initialize and configure
the peripheral, manage data transfer based on polling, interrupts or DMA processes
and manage any communication errors that may raise.
The HAL Drivers APIs are split into two categories:
–
–
Basic peripheral usage examples: this layer covers the examples for the STM32
peripheral using the HAL and BSP resources.
generic APIs with common and generic functions for the entire STM32 series
extension APIs with special functions for a specific family or part number
•
•
Level 1 is divided into two sub-layers:
•
Middleware components: set of libraries covering USB Host and Device libraries,
STemWin, FreeRTOS, FatFS, LwIP and PolarSSL. Horizontal interaction between the
components on this layer is performed directly by calling the feature APIs, while the
vertical interaction with the low-level drivers is managed through specific callbacks and
static macros implemented in the library system call interface.
For example, the FatFs implements the disk I/O driver to access the microSD drive or
the USB Mass Storage Class.
Examples based on the middleware components: each middleware component
comes with one or more examples (or ‘applications’) demonstrating how it is used.
Integration examples that use several middleware components are also provided.
•
Level 2 provides comprehensive, real-time and graphical demonstrations of the middleware
service layer, the low-level abstraction layer and basic peripheral usage applications for
board-based functions.
DocID027906 Rev 1
5/24
24
X-CUBE-MEMSMIC1 software expansion for STM32Cube
UM1901
2
2.1
X-CUBE-MEMSMIC1 software expansion for
STM32Cube
Overview
The X-CUBE-MEMSMIC1 software package expands STM32Cube functionality with the
following key features:
•
comprehensive middleware to build applications using digital MEMS microphones
(MP34DT01-M)
easy portability across different MCU families thanks to STM32Cube
a customized audio-input class USB driver so the device is recognized as a standard
multichannel USB microphone
PC-based streaming and recording using standard third-party audio editors
free user-friendly license terms
example applications available for the X-NUCLEO-CCA02M1 board connected on a
NUCLEO-F401RE, NUCLEO- L053R8 or NUCLEO-F072RB board
•
•
•
•
•
This software enables the acquisition of up to four digital MEMS microphones through I²S
and SPI peripherals and performs PDM to PCM format conversion, the main standard for
audio communication and processing.
Exploiting the capabilities of the included audio-input USB driver, the device is recognized
as a standard multichannel USB microphone by Windows™ or any Unix-like system; it can
perform signal streaming to a host system for data recording and further processing using
any standard audio editor, even if any software with a standard USB audio interface can be
used to interact with the device.
2.2
Architecture
This software is fully compliant with and expands on the STM32Cube (see Section 1:
STM32Cube) to enable development of applications using digital MEMS microphones.
The software is based on STM32CubeHAL, the hardware abstraction layer for the STM32
microcontroller. The package extends STM32Cube by providing a board support package
(BSP) for the microphone expansion board and middleware components for audio
processing and USB communication with a PC.
The software layers used by the application software to access and use the microphone
expansion board are:
•
STM32Cube HAL layer: provides a generic, multi-instance set of APIs to interact with
the upper layers (the application, libraries and stacks). It consists of generic and
extension APIs based on a common architecture which allows other layers like the
middleware layer to function without specific Microcontroller Unit (MCU) hardware
configurations.
This structure improves library code reusability and guarantees easy device portability.
Board Support Package (BSP) layer: is a set of APIs which provides a programming
interface for certain board specific peripherals (LED, user button etc.). This interface
also helps in identifying the specific board version and provides support for initializing
required MCU peripherals and reading data.
•
6/24
DocID027906 Rev 1
UM1901
X-CUBE-MEMSMIC1 software expansion for STM32Cube
For the microphone expansion board, it provides the interface for MP34DT01-M digital
MEMS microphones.
The figure below outlines the software architecture of the package.
Figure 2. X-CUBE-MEMSMIC1 software architecture
2.3
Folder structure
Figure 3. X-CUBE-MEMSMIC1 package folder structure
The following folders are included in the software package:
•
‘Documentation’: contains a compiled HTML file generated from the source code and
detailed documentation of the software components and APIs
‘Drivers’: contains the HAL drivers and the board-specific drivers for supported board
and hardware platforms, including those for the on-board components and the CMSIS
vendor-independent hardware abstraction layer for the Cortex-M processor series
‘Middlewares’: contains libraries and protocols for the PDM to PCM conversion process
and the audio-input USB driver
‘Projects’: contains a sample application for the NUCLEO-F401RE, NUCLEO-L053R8
or NUCLEO-F072RB platforms to access microphone data, with three development
•
•
•
DocID027906 Rev 1
7/24
24
X-CUBE-MEMSMIC1 software expansion for STM32Cube
UM1901
environments (IAR Embedded Workbench for ARM, RealView Microcontroller
Development Kit (MDK-ARM) and System Workbench for STM32 (SW4STM32)
2.4
2.5
APIs
Detailed descritions of all the functions and parameters of the user APIs user can be found
in a compiled HTML file located inside the ‘Documentation’ folder.
Sample application description
An example application using the X-NUCLEO-CCA02M1 expansion board with NUCLEO-
F401RE, NUCLEO-L053R8 or NUCLEO-F072RB boards is provided in the ‘Projects’
directory. Ready to be built projects are available for multiple IDEs.
2.5.1
Hardware-related acquisition processes
This section summarizes the digital MEMS microphone acquisition strategies and principles
used in the application. It can simplify the comprehension of the firmware structure and
utilization.
A digital MEMS microphone can be acquired through peripherals such as SPI, I²S or GPIO.
It requires an input clock and it outputs a PDM stream at the same frequency of the input
clock. This PDM stream has to be filtered and decimated in order to be converted in
standard PCM format. Two different digital MEMS microphones can be connected on the
same data line by configuring the first to generate valid data on the rising edge of the clock
and the other on the falling edge. This is achieved by setting the L/R pin of each
microphone.
On the X-NUCLEO-CCA02M1 expansion board, two microphones share the same data line
and are routed to the Nucleo I²S peripheral (the first and the second microphone) and SPI
peripheral (the third and the fourth).
In this scenario, microphone acquisition works thus:
•
a precise clock signal is generated by I²S peripheral while SPI is configured in slave
mode and is fed by the same timing signal generated by I²S
this clock is then halved by a timer and input to the microphones
the SPI and I²S peripherals operate at twice the microphone frequency and can
therefore read the data for two microphones each by reading the rising and falling edge
of the microphone clock; acquisition is managed by the DMA
a software demuxing step is required to separate the signal for each microphone to
allow further processing like PDM to PCM conversion
•
•
•
Figure 4 shows a simplified diagram of the acquisition process. To acquire a single
microphone only, I²S is used and the MEMS microphone is connected directly to its clock
and data line. In this case, I²S and the microphone operate at the same frequency.
For further information regarding MEMS microphone and PDM to PCM filtering and
decimation, please refer to [1] and [2].
8/24
DocID027906 Rev 1