2023-10-04 11:36 PM
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
Solved! Go to Solution.
2023-10-12 02:18 AM
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!).