AnsweredAssumed Answered

stm32f4 discovery mems microphone over i2s cant get it running

Question asked by Jan Slavotínek on Dec 6, 2016
Latest reply on Dec 13, 2016 by Jan Slavotínek

Hi community! 


Jan Here, Cezch Republic. 
I am working on my project where i need to process audio for further uses. My first step is obviously get my data from mic. I have decided to use the MP45DT02 MEMS mic that is present on my stm32f4 discovery board. 


I have already successfully got working example (Audio_playback_and_record). I used that example to help me understand basics of .wav and also pdm lib. I have also observed settings necessary for setting up i2s2. I replicated those settings using CubeMX and created project. Now i am facing following problem:


I never receive interrupt when debugging ( SPI2_IRQHandler(); is never called). So what am I missing? I have thoroughlly read through comments at stm32f4xx_hal_i2s.c librarry. I believe most of the actions (settings) were actually made by CubeMX so i dont need to do anyting. I would expect i2c start generating clock for the MEMS mic and i would expect pdm stream to start flowing. But its not. So i said to my self, that it is necesarrry to call some kind of start function to get the peripherral running (like when using ADC's one need to call HAL_ADC_Start_IT(&hadcx)), but i cant find any "i2s_start()" function at the library. 


Any help would be appreciated!



The I2S HAL driver can be used as follow:

(#) Declare a I2S_HandleTypeDef handle structure.
(#) Initialize the I2S low level resources by implement the HAL_I2S_MspInit() API:
(##) Enable the SPIx interface clock.
(##) I2S pins configuration:
(+++) Enable the clock for the I2S GPIOs.
(+++) Configure these I2S pins as alternate function pull-up.
(##) NVIC configuration if you need to use interrupt process (HAL_I2S_Transmit_IT()
and HAL_I2S_Receive_IT() APIs).
(+++) Configure the I2Sx interrupt priority.
(+++) Enable the NVIC I2S IRQ handle.
(##) DMA Configuration if you need to use DMA process (HAL_I2S_Transmit_DMA()
and HAL_I2S_Receive_DMA() APIs:
(+++) Declare a DMA handle structure for the Tx/Rx stream.
(+++) Enable the DMAx interface clock.
(+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
(+++) Configure the DMA Tx/Rx Stream.
(+++) Associate the initialized DMA handle to the I2S DMA Tx/Rx handle.
(+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the
DMA Tx/Rx Stream.

(#) Program the Mode, Standard, Data Format, MCLK Output, Audio frequency and Polarity
using HAL_I2S_Init() function.

-@- The specific I2S interrupts (Transmission complete interrupt,
RXNE interrupt and Error Interrupts) will be managed using the macros
__I2S_ENABLE_IT() and __I2S_DISABLE_IT() inside the transmit and receive process.
-@- Make sure that either:
(+@) I2S PLL is configured or
(+@) External clock source is configured after setting correctly
the define constant EXTERNAL_CLOCK_VALUE in the stm32f4xx_hal_conf.h file.