cancel
Showing results for 
Search instead for 
Did you mean: 

HAL I2S timeout error

uahma
Associate

HAL I2S timeout error, look at my code below, i had it working one day and now it never works, the HAL_I2S_Receive function is only called once and then I run into HAL_StatusTypeDef being stuck in HAL_TIMEOUT.

while (1)
 
 {
 
   /* USER CODE END WHILE */
 
 /* USER CODE BEGIN 3 */
 
   HAL_StatusTypeDef result = HAL_I2S_Receive(&hi2s1, (uint16_t*)I2S_RX_BUFFER, 24, 100);
 
   HAL_Delay(500);
 
   if(result == HAL_OK){
 
     volatile int32_t data_full = (int32_t) I2S_RX_BUFFER[0] << 16 | I2S_RX_BUFFER[1];
 
     volatile int16_t data_short = (int16_t) I2S_RX_BUFFER[0];
     
 
     volatile uint32_t counter = 2;
 
     while(counter--);
 
     HAL_Delay(500);
 
   }
 
  }

I did make use of __HAL_DBGMCU_UNFREEZE_IWDG() before my HAL_Init(); command but still it does not work. I swear it worked once and i was able to get different sensor data while debugging with GDB server but not anymore and this is driving me crazy.

my code is stuck in result = HAL_TIMEOUT .....

2 REPLIES 2
Amel NASRI
ST Employee

Hello,

Please:

  1. use a meaningful title/summary for your question
  2. use "Code Snippet" icon to insert code
  3. precise the device you are using

I edited your question to make these updates. This way, your question will be easier to understand, and you will have more chance to get an answer.

Thanks for your understanding.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

uahma
Associate

Thanks Amel.