2025-03-27 12:51 AM
I am using STM32F407VG in my project temporarily. The objective is to transmit audio data over ethernet which is received in this mic and received audio from the other end this side having stm32 as the MCU.
For Mic, I am using SPH0645. But I am unable to sample the audio correctly. I am facing the same issue as in the following link.
https://community.st.com/t5/stm32-mcus-products/unexpected-behaviors-in-dma-buffer-for-i2s-mems-microphone/td-p/725679
my_code:
uint16_t data_in[100] = { 0 };
volatile int16_t sample_i2s;
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) {
sample_i2s = data_in[0];
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2S2_Init();
/* USER CODE BEGIN 2 */
HAL_I2S_Receive_DMA(&hi2s2,(uint16_t*)&data_in[0],100);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
i am unable to read the I2S audio buffer properly.
The output when i plot the variable "sample_i2s" is
Note:
STM32F407VG board is chosen just because it has I2S pins. For transferring via the Ethernet, I am going to use STM32F767ZI and I am using this Discovery board for time being. So if anyone have a solution, Kindly do reply in the same thread.
Thank You.