samd21 fast adc sampling for wav file recording

Hi,

I have been trying to record wav file on arduino mkr zero(SAMD21) for quiet some time now with analog mems mic, have been successful doing that but recording is not stable because of slow adc sampling. I have tried polling , interrupt(dual-buffer) and event system technique for fast adc sampling but i don't know each of them gives me inaccurate results. Attached code is for recording 16bit,48khz wav file for 10sec but file it only creates 7-8 sec wav file.

recording.ino (16.3 KB)

but recording is not stable because of slow adc sampling.

You sure of that. I would say it is the writing of large buffers that is causing you to miss interrupts. Have you tried simply holding the SD card file open and writing bytes to that as you get them?

Have you tried simply holding the SD card file open and writing bytes to that as you get them?

yes i have tried that,also with small buffer size but results are same.