cancel
Showing results for 
Search instead for 
Did you mean: 

How to use TIM with SPI to acquire audio data from MEMS microphone

UTANG.1
Associate II

Hello 😊

I'm using the microphones on the X-NUCLEO-CCA02M2 Digital MEMS microphones expansion board based on MP34DT01-M for STM32 Nucleo. This card is plugged on nucleo stm32h743zi2

My problem is that I have to interface two microphones in stereo using a timer and the SPI and then stream the data via USB and i dont know how to do it.

Someone can tell me what is the configuration to adopt on cubeMX for the TIMER and SPI setup

Here's what I want to do:

0693W000001sGcXQAU.png

And also what HAL functions I need to include in my program.

If someone have explanations, it would be very nice 😊

4 REPLIES 4
Eleon BORLINI
ST Employee

Hi @UTANG.1​ , did you already check the X-CUBE-MEMSMIC1 examples? For example, the project in folder path: Projects\STM32F746ZG-Nucleo\Demonstration\CCA02M2\Microphones_Streaming, although not directly implemented on STM32H7 MCU. As reported in the description of the library:

[...] the microphones are routed to nucleo I2S peripheral (the first and the second) and SPI peripheral (the third and the fourth). In this scenario the microphones acquisition works in this way: a precise clock is generated by I2S peripheral while SPI is configured in slave mode and is fed by the same timing signal generated by I2S. This clock is then halved by a timer and given in input to the microphones: the SPI and I2S peripherals  are working at a frequency that is twice the microphone frequency, so that they  can read data on both the rising and falling edge of the microphone clock,  thus reading the bits of two microphones each. A software step of demuxing is required in order to separate the signal from the two microphones and allows further processing like PDM to PCM conversion. 

I add STM32H7 tag for broader audience and help. Regards

UTANG.1
Associate II

Thank you for your response,

I have taken a closer look at this project and I understand my problem better. But there's something I never understand about this type of project. In the project datasheet (X-CUBE-MEMSMIC1) as well as in many other projects I see this.

0693W000001sMAoQAM.png

Easy portablility across different MCU families ? What does that mean exactly ? stmh7 is included?

Or is it just about the nuclear maps listed at the bottom of the picture?

These libraries (CCA02M1_AUDIO_H + CCA02M1_AUDIO_C) from the project (X-CUBE-MEMSMIC1) are they usable for an stmh7 map if not how to adapt them (if possible).

If I create a project with cubeMX with an h7 nucleo and I add these libraries and update the peripherals (SPI/I2S) it will work?

U.TANG

UTANG.1
Associate II

@Eleon BORLINI​ 

Eleon BORLINI
ST Employee

Hi @UTANG.1​ , this option:

>> If I create a project with cubeMX with an h7 nucleo and I add these libraries and update the peripherals (SPI/I2S) it will work?

should work. Changing the core STM32 hw will however change also the physical pins declarations in the code libraries. But i believe that our STM32 MCUs colleague are more expert about this topic...

Regards