cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Microphone MEMS Output

ALope.1
Associate II

Hello everyone,

I'm testing a MP34DT05 digital MEMS microphone, and my goal is to record direct values to a python file. After this, I will do the decimation in my computer (to get comfortable with the data)-

I was thinking about receiving data by a COM PORT via USART, but now I'm thinking about the problem of exceeding the baud rate of USART, because I'm recording sound at a rate of 48kHz.

I'm seeing the buffer being filled through the live expression of Atomic Studio. The perfect thing would be to catch all the values by IDE, but, to the best of my knowledge, it is not possible with this IDE, right?

Thank you for your attention, and I hope I can learn a little more with this message.

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @ALope.1​ , if you are acquiring with frequency 48kHz, I assume your PDM frequency is 3.072MHz (mic clock): in this case you need a very fast UART, and for this reason it is difficult to use a VCOM port on your PC. There are however two possibilities to proceed, we believe:

First possibility, in the Atollic debugger you could:

  • Declare a huge variable, up to the maximum memory capability;
  • Stop the acquisition after some time (better with the “complete�? DMA interrupt, disabling the DMA just after, otherwise you will overwrite the debug buffer);
  • Try to log/download the huge variable containing the PDM acquired stream (sure it is possible with IAR, should be also in Atollic)

This way you will be able to get a discrete amount of recorded milliseconds: 1 second are equal to 375 kByte, you can manage it with your microcontroller depending the part number you choose (STM32F7 and STM32H7 are the most powerful families for this purpose).

Second (but more complex) possibility: you can use the debugger SWO signal, that enables you to log variables (not sure in Atollic, but working with IAR). It depends also on the speed pf the physical debugger you are using (for example, STLINK v2 is slower than STLINK v3…)

Last but not least, Atollic is a NRND tool, in practice: it is better to use STM32CubeIDE programming tool.

Regards

View solution in original post

5 REPLIES 5
Eleon BORLINI
ST Employee

Hi @ALope.1​ , if you are acquiring with frequency 48kHz, I assume your PDM frequency is 3.072MHz (mic clock): in this case you need a very fast UART, and for this reason it is difficult to use a VCOM port on your PC. There are however two possibilities to proceed, we believe:

First possibility, in the Atollic debugger you could:

  • Declare a huge variable, up to the maximum memory capability;
  • Stop the acquisition after some time (better with the “complete�? DMA interrupt, disabling the DMA just after, otherwise you will overwrite the debug buffer);
  • Try to log/download the huge variable containing the PDM acquired stream (sure it is possible with IAR, should be also in Atollic)

This way you will be able to get a discrete amount of recorded milliseconds: 1 second are equal to 375 kByte, you can manage it with your microcontroller depending the part number you choose (STM32F7 and STM32H7 are the most powerful families for this purpose).

Second (but more complex) possibility: you can use the debugger SWO signal, that enables you to log variables (not sure in Atollic, but working with IAR). It depends also on the speed pf the physical debugger you are using (for example, STLINK v2 is slower than STLINK v3…)

Last but not least, Atollic is a NRND tool, in practice: it is better to use STM32CubeIDE programming tool.

Regards

Thank u! Your answer really help to synthesize my ideas.

Before the question, I already had tried to fill up the buffer. Unfortunately, I'm working with one L4 Nucleo Board which doesn't have the capacity to full more than 1 second in RAM.

I have more 2 last questions questions that I believe being newbie questions...

1) I read the app note where it is referred that the clock should be higher than 64 times the sampling frequency what results in 3.072 MHz value. But I don't the reason of this value and if we can configure with a higher value..in my case my MCU is not able to fit this value, so i'm working with a >4 MHz mic clock.

2) I am using STM32CubeIDE .. I think they are the same (the old Atollic True Studio). In this IDE, is it possible to record data? I mean, in "live expressions", I can see the buffer constantly changing with new values ​​...

I hope you can help! Thank you again

chaaalyy
Senior II

Just a "stupid" idea...

If you want to transfer the data to your pc: I don´t think it´s necessary to do that in "realtime". So why not buffering the data directly to a uSD card via DMA (SDIO, not SPI mode...) and read it later on your pc ?

hello, it's not "stupid" because it is my final goal :)

My question is because I'm trying to understand if my microphone is doing the right thing. Thank you

Hi @ALope.1​ , don't think they are newbie question, but let's check if I can answer:

1) About the microphone clock, considering also the previous ansewr, the SAI or I2S clock peripheral freqeuncy is given by the formula:

fs * n_channels * n_bits_per_channel

For this reason, for example, if I configure the peripherals for 2 channels, 48 KHz, 32 bits I'll have a clock 48000 *2 *32 = 3.072 MHz.

So, to summarize about the clock: you have to configure the clock tree as suggested before to tune the SAI input, that should be as close as possible to typical audio quartz frequency, such as 49.152 MHz or 12.288 MHz. You set the SAI/I2S with the correct parameters (channels, fs, bits) to get a correct OUTPUT clock, that is in practice the microphone clock.

2) About the debugger topic (i.e., for example, a question such as "how to log data at XX bps from Atollic debugger"), it depends on the hardware you are using, but for this topic the STM32 community.

Regards