2025-09-10 7:36 AM
Hi, i encountered the problem on my stm32 G474RE board, that when i use the adc in dma mode i can not use a dac. The dac simply does not work. As long as i dont start the adc in dma mode, my dac is generating the right waveform, but when i start the adc the dac_setValue function is stuck and wont update? Has anybody encountered that problem? Am i doing something wrong?
2025-09-10 7:39 AM
Your ADC interrupts are triggering so fast it prevents the code from doing anything else. Decrease ADC sample rate, increase DMA buffer size. Increasing the sample rate to max is generally beneficial.
2025-09-11 1:12 AM
But how can i then use the maximum sampling frequency of the adc? The MCU clock is set to 120MHz so it should be way faster than the ADC sampling frequency. Is there just too much overhead, with the HAL libraries? I basically want to compare consecutive adc values in real time to react on them. Measuring a ton of values and buffering them is not suitable for my application.
2025-09-11 6:16 AM - edited 2025-09-11 6:16 AM
Code takes time to run. You can't react to every sample at max sample rate immediately after it happens. The CPU can't keep up.
2025-09-11 10:25 AM
To use simple compare operation to pre-defined values you can configure AWD:
Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL,
AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)
The three AWD analog watchdogs monitor whether some channels remain within a
configured voltage range (window).
For more advanced algorithm of data processing consider to sample a small array, 10-20 samples and work in interrupt. Highly optimized code may get speed above 2-4 msps that adc could stream at max
2025-09-12 3:08 AM
Unless you're doing some real-time processing on each sample, use big buffers for AD and DA data, combined with DMA.
And for getting (even more) help:
show your relevant code snippets, using the </> button.
Some people don't have time / want to download and unzip.