2016-11-05 07:44 AM
Hi Everybody!
I've successfully implemented USB Audio device, utilising onboard cs43l22 DAC and it works well, except one annoying thing: it emits periodic noise in analog output, mixed to normal sound. I noticed, that it is rigidly bound to the moment whenHAL_I2S_Transmit_DMA is called to send new data to DAC. I have captured the sound by Audacity and here how it looks like. Can anyone suggest the nature of that noise and how it could be fixed?
Thank you,Stan:
#stm32f4-disc1-cs43l22-usb-noise2016-11-06 10:27 AM
Looks like 1kHz, which is the frequency of USB packets arrival. Buffer over/under-run? (i.e. playing back faster/slower than USB supplies the data)
JW2016-11-07 10:03 AM
Hi! I use standard ST's audio class driver with one buffer and HalfBuf DMA callback, where sync adjustment is managed. The only thing I added is call to HAL_I2S_Transmit_DMA.
In the end, it looks like cs overlaps two buffers (!).... I have generated different tones and visualized 'em and saw that the overlapping continues 1800 samples. This window is split by 50 sample fragments (36 fragments in total). These 50 samples are assembled in different proportion of ''old'' buffer and ''new'' one (see pic). The period, when this ''overlapping'' happens depends upon the size of buffer in the manner that the shorter is the buffer, the more often ''overlaps'' I observe. If it happened due to being not in sync with arriving data, such ''overlaps'' would happen with constant period, but it is not - it happens only when HAL command is issued for next transfer and the length of that sh.t is always has same length - 1800 samples. Further, when I used sample frequency, multiple 50 Hz, no overlaps were observed...