1

I'm trying to interface these SPH0645 Mics (I2S) to a STM32f767ZI board.

I have wired it correctly, now just trying to test the mic by passing the data through UART to my pc. Hoping someone can point me in the correct direction.

I have tried passing straight to the UART transmit. However I think I may need some datahandling - I am receiving from the UART, but sometimes just 0 or other times just gibberish which is not from the Mic as it still transmits even when i disconnect the mic.

I2S mic is receiving data in 24 bits in 32 bit frame, the last 8 bits are junk. The protocol is Big Endian, I am thinking that the HAL library handles this, however I am not completely sure.

uint16_t data;
while (1)
 {
/* USER CODE END WHILE */
HAL_StatusTypeDef result= HAL_I2S_Receive(&hi2s1,&data,2,100);

HAL_UART_Transmit(&huart3,&data,2,100);
/* USER CODE BEGIN 3 */
 }
/* USER CODE END 3 */
}  

What did I miss?

1 Answers1

0
  1. Check the return value of HAL_I2S_Receive(&hi2s1, &data, 1, 100)

  2. Did you verify HAL_I2S_Receive expects uint32_t* as 2nd argument? I think it shall expect uint16_t*

  3. Using HAL_UART_Transmit you want to transmit the data over UART. Shouldn't you pass data as an argument to HAL_UART_Transmit ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
nivpeled
  • 1,810
  • 5
  • 17
  • Sorry, I accidentally displayed a test code which was going to test if the UART transmit worked. - It successfully transmits 'storage' , I have edited my question to reflect my mistake. – Vikranth Ghandi Aug 05 '19 at 07:37