STM32 interrupt causing noise on DAC output - Page 1
Forum section: electronics / beginners

author: ratatax
author_rank: Regular Contributor
timestamp: December 03, 2020, 01:29:11 pm
content: Hi,I'm using an STM32F7 with its internal DAC for an audio project.It works but my VDD (3.3V) is fluctuating due to current draw from the MCU at fixed intervals (each time my 250Hz interrupt happens), which causes the DAC to output a "pulse-like" waveform, not very loud but clearly hearable.I can reduce the fluctuations by putting a large (1000uF) capacitor between VDD and GND, but it doesn't removes it completely.Power comes from +5V regulated to 3.3V by an LDO.Adding even more capacitance sounds like a bad brute-force method, do you think of solutions to make VDD immune to load fluctuations from the MCU ? On the STM32 there is a VDDA pin which I connect directly to VDD. Maybe an LC filter between them to prevent ripple on digital supply to get over the analog supply ? But it's 250Hz noise with a pulse-shape (many harmonics), how could I filter that ?

author: Siwastaja
author_rank: Super Contributor
timestamp: December 03, 2020, 01:49:30 pm
content: At high frequencies (>10MHz), LC out of "actual" inductor, or at >50MHz, a ferrite bead. Be careful not to create more problems than you solve (i.e., resonance)At low frequencies (<1MHz), any linear regulator. Seems this is your case.Between these, certain specific linear regulators rated for good PSRR at high frequency. Shop around.Trying to filter low such low frequency disturbances means large values of L and C, not practical. You would be storing quite a bit of energy. Instead, you have power available at the input; regulate it!In other words, copy-pasta your existing 3V3 regulator so that VDDA has its own, this is easy because no extra BOM lines to order. If high-frequency noise (outside the PSRR of the regulator) is a problem, add LC (or ferrite bead) to the input side of that regulator.

author: AndyC_772
author_rank: Super Contributor
timestamp: December 03, 2020, 01:59:46 pm
content: Bear in mind, what you really need is for VDD to be smoothat the DAC, which is physically located on the die. It's separated from any filtering you apply externally by a bond wire, copper lead frame and on-die routing, all of which have inductance and resistance that you can't do anything about.Since the problem is at audio frequencies, the root cause is probably related more to resistance than inductance. I'd start by looking to see what might be changing the static current draw of the CPU each time the interrupt is triggered; if the current draw of the CPU changes, then even with perfect filtering right by the pins, the IR voltage drop across the die and packaging can still mean that the exact value of VDD changes where it matters most.Does your CPU have any I/O pins which are sinking or sourcing non-trivial amounts of current?What does your 250 Hz interrupt actually do?

author: ratatax
author_rank: Regular Contributor
timestamp: December 03, 2020, 02:23:01 pm
content: QuoteNoQuoteIt fills an audio buffer in memory, which is automatically transferred to the DAC via DMA. Outside the interrupt, the main thread is an empty while loop. Maybe I should try doing some stuff in it, just to prevent any optimization from putting the MCU is some sort of low-power mode each time an interrupt finishesQuoteThat seems to be a really good idea, i'll try it for sure !My regulator is a fairly standard AMS1117-3.3

author: aheid
author_rank: Regular Contributor
timestamp: December 04, 2020, 05:57:23 am
content: I seem to recall some timing and relative voltage requirements of VDDA vs VDD on the STM32s, but then again I've seen some designs which seem to pretty much ignore this so I don't know how much is theoretical datasheet talk or not.

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: December 04, 2020, 06:57:45 am
content: Filtering VDDA may still help if what's coupling in is a harmonic of your ISR frequency and not the fundamental.Also double check that you don't have an off-by-one error in your ISR when transferring a block of audio, dropping a sample can cause a click.

author: Siwastaja
author_rank: Super Contributor
timestamp: December 05, 2020, 09:22:50 am
content: Quote from: aheid on December 04, 2020, 05:57:23 amYes, a diode between VDDA and VDD is needed to satisfy the power sequencing requirements. It likely seems to work without just fine though given the same regulator IC with same amount of output capacitance.