Docs

Micro-controllers, wireless transmission and database

Head

INMP441 I2S Sound with Nucleo STM32F446RE using STM32CubeIDE

Prerequisites

This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic blink sketch with Nucleo STM32F446RE using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=oAwZ0cjlmN8

Wiring Diagram

Diagram1 Diagram2 Diagram3

STM32CubeIDE Settings

Click Multimedia → Click I2S2 →

Mode set to Half-Duplex Master

Configuration → Parameter Settings →

Transmission Mode set to Mode Master Transmit

Data and Frame Format set to 16 Bits data on 16 bits frame

Selected Audia Frequency 16KHz

Click DMA Settings Tab → Click Add button

Select TX → Data width to Half word

Click Multimedia → Click I2S3 →

Mode set to Half-Duplex Master

Configuration → Parameter Settings →

Transmission Mode set to Mode Master Receive

Data and Frame Format set to 16 Bits data on 16 bits frame

Selected Audia Frequency 16KHz

Click DMA Settings Tab → Click Add button

Select RX → Data width to Half word

Additional code on top of STM32CubeIDE generated code

/* USER CODE BEGIN 0 */
uint16_t toReceive;
uint16_t toWrite;
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s){
    toWrite = toReceive;
    HAL_I2S_Transmit_DMA(&hi2s2, &toWrite, 1);
    HAL_I2S_Receive_DMA(hi2s, &toReceive, 1);
}
/* USER CODE END 0 */

/* USER CODE BEGIN 2 */
HAL_I2S_Receive_DMA(&hi2s3, &toReceive, 1);
/* USER CODE END 2 */


Break 16 bit data for transmission and reconstruction

             uint16_t toWrite;
             uint8_t Broken1;
             uint8_t Broken2;
             Broken1 = toWrite & 0xff; 
             Broken2 = toWrite >> 8; 

             uint16_t Reconstructed;
             Reconstructed = ((uint16_t)Broken2 << 8) | Broken1;