cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H750 with I2S non blocking-mode (DMA or IT) works only once

pk84
Senior

Hello,

As mentioned in the title, I am trying to output a simple sinusoidal audio over I2S.
It works only the first time with DMA and IT, but not afterwards.
In blocking mode it works fine. See the code below.

Does somebody maybe know why?? (It doesn't matter how long the HAL_Delay is)

 

for(uint16_t i = 0; i < 3; i++){
  HAL_Delay(1500);
  HAL_I2S_Transmit(&hi2s2, (uint16_t*)signal1, nsamples, 150); // get a sound 3 times
  //HAL_I2S_Transmit_IT(&hi2s2, (uint16_t*)signal1, nsamples); // sound only once
  //HAL_I2S_Transmit_DMA(&hi2s2, (uint16_t*)signal1, nsamples); // sound only once
}

 


Thank you

10 REPLIES 10
LCE
Principal

Maybe it's not necessary if your buffer has a clean sine from start to end of buffer.
So check your buffer content.

Otherwise :

HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, const uint16_t *pData, uint16_t Size);

Set "Size" (in your case "nsamples") to the sine length.
The size you hand over to DMA can be smaller than the actual buffer size (but must NOT be bigger!).