Why is the SAI (I2S) used in DMA mode generate noise
I am using a SAI device on a SMT32WB55. Using it as a wavetable synth that produces a triangle wave.
I am able to play my triangle wave for x amount of time with
HAL_SAI_Transmit_DMA(&hsai_BlockA1, (uint8_t*)data, size);And later stop it with a timer using :
HAL_StatusTypeDef status = HAL_SAI_DMAStop(&hsai_BlockA1);Whichever frequency I use for my triangle wave, the sound is fine. However, if I play another note after the first one, I can ear so pop/clicks/tearing that gets worst after each note. If I play diferent notes, I can still hear a trail of the previous note before the right frequency kicks in.
Everything is reset in the triangle wave generator after each note and the array assigned to the dma circular buffer in the transmit function is memset to 0 just in case.
After inspecting the HAL code for the HAL_SAI_DMAStop function, I can see that the dma requests are stopped and the fifo is cleared. So there should be no residual data when DMAStop is called.
Is there something I am missing?
Thank you.