I2S audio crackly noise on STM32L05x
Hello everyone!
I am struggling with playback via I2S to external DAC on STM32L051/53.
Audio:
file in external SPI flash,
WAV format
16KHz sampling rate
16bit depth
I run the core on internal oscillator.
My 'real' I2S clock (WS frequency) is 15,957kHz, which is -0.26% off the target sampling frequency.
This is pretty accurate with my read from oscilloscope.
I send 16 bits of data on 16-bit frame.
External DAC:
UDA1334
min. 16KHz sampling rate
16bit I2S Phillips compatible
I cannot fit even 1s audio to MCUs memory, so I am reading from external flash using DMA.
My algorithm:
2x 512byte uint8_t array (let's say bufferA and bufferB)
2x 256 byte uint16_t array (let's say bufferC and bufferD)
read 512byte chunk of audio to bufferA
read 512 byte chunk of audio to bufferB
convert bufferA to bufferC
transmit bufferC to I2S
on i2sHalfCpltCallback update bufferA or bufferB
on spiRxTxCpltCallback convert bufferA to bufferC or bufferB to bufferD
while (!endOfFile)
i2sTransmit (bufferC or bufferD)
The actual questions:
Can 0.26% devation on I2S clock cause crackly noises during playback?
Is it possible to calculate/esitmate the THD based on I2S clock devation?
If I was handling big-endian/little-endian wrong I would not hear the audio at all, right?
What can I look into further to investigate the issue?
