MKRZERO i2s audio errors

Dear all,

While tinkering around with the MKRZERO and the waveplayback (ArduinoSound lib) example, I found something that I thought would be interesting to share.

I have made a small PCB prototype board where the MKRZERO is streaming i2s data to an amplifier (Infineon MA12070P to efficiently drive some serious speakers) in this case - using bit clock, word, clock, and data. Initially I used the waveplayback example code, which seemed to work fine. However, in a later stadium of prototyping I experienced kind of "crackling" noise and slight "synthesized" errors in the audio playback. First I thought something was wrong in my design, e.g. bad grounding, i2s clocking error, i2s format, etc.

After debugging pretty much everything I could think of, I tried a couple of different SD cards, which all gave slightly different "noise" signatures. This made me to believe that the example code and libs are quite sensitive to either SD card quality and/or read speed of the SD card.

Bought some fresh SD cards: "Verbatim 16GB 45MB/sec" and "Verbatim 16GB 80MB/sec". The latter one works with almost no noise or synthesized artifacts, while the first one has a very audible artifacts every couple of minute or so - sounds like synthesized errors / double audio samples or something like that.

This leads me to believe that there is some kind of buffer underflow or overflow in the process of reading sd card audio and processing it for i2s stream. Maybe somebody here knows something more about this.

Anyway, solution for now is: fast enough SD card - 80MB/sec works for me.

This leads me to believe that there is some kind of buffer underflow or overflow in the process of reading sd card

I think you are right. An SD card is not just a simple memory device. It contains its own operating system to keep a map of bad sectors and stop you using them. It could just be that a higher quality card produces less bad sectors or it is more successful at identifying them and masking them out.

It is possible that the code is not using any buffers at all and is just getting bytes when it needs them.