I am doing my own project making a basic audio recording device using microcontroller's ADC to get the audio signal from electret microphone and saving data to microSD card. I'm using STM32L476RG Nucleo board and external discrete components. Below is the simplified schematic of the application.
There is an anti-aliasing filter (440 ohm resistor and 100nF capacitor). Removing it does not change results.
The ADC works based on 8 kHz timer output in DMA mode, so my code based on ADC control is pretty simple: I start the timer and ADC in DMA mode and wait for half complete and full complete interrupts where I simply write ADC data to microSD, then the cycle continues and the audio data is continuous in the time axis.
The problem arises when writing data once the half complete or full complete DMA interrupt occurs. During that time the current increases (that's my hypothesis) and the voltage on the VDDA (ADC source/reference pin) changes. The consequent result - periodical spikes in the audio data exactly at the time of DMA half/full conversion complete interrupt. As of approval I tested changing SPI speed (for microSD communication) which showed that reducing speed had longer spikes and increasing speed had shorter spikes.
So there is the 8 bit audio signal in Audacity. The upper signal is while talking and the lower is being in silence. The audio recording excluding the regular ticking (spikes) is completely fine.
I have tried bypass capacitors and filters which did not improve the audio. Also tried using CR2032 cell battery for microSD, but apparently the voltage was too low for microSD to function.
Are there any hardware or software decisions/solutions I can implement that would get rid of this problem? I prefer fixing it in hardware first, but keep using the MCU's ADC.
There is the schematic of Nucleo Board for MCU and VDDA/reference pin powering.