cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G03 DMA initialization causing uwanted effects on Systick

yIzumi
Associate II

Hi everyone,

Im havinga annoying problem, im trying to inialize the DMA with the ADC , on my custom board. when a initlize it, it works fine, i get the 3 values of the trhee adc channel stored on a buffer. But the Systick timer goes crazy. i get way more faster than it should. the MCU its running on 16Mhz HSI,the interrupt that should be 1ms, goes as low as100uS.

 The strange thing, is that, whenever the DMA is not initalized, the systick runs rigth. Any ideas of wath could cause this?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Probably DMA is falling behind, causing you to misinterpret systick as speeding up. Reduce ADC sample rate to ~1000 Hz to test.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
GwenoleB
ST Employee

Hello @yIzumi ,
Is there DMA interrupt enabled? If your ADC is running in continuous mode with DMA transfer, the DMA interrupt could happen quickly. Consequently, your interrupts could be delayed.
Please try first to disable DMA interrupt or slow down ADC sample rate.

For now, I'm not able to reproduce it on my side. So, if nothing change, feel free to share your project.

Best Regards,

Gwénolé

TDK
Guru

Probably DMA is falling behind, causing you to misinterpret systick as speeding up. Reduce ADC sample rate to ~1000 Hz to test.

If you feel a post has answered your question, please click "Accept as Solution".

Hi gwénolé, thanks for the quick reply and sorry for my grammar errors.
So, i disabled the DMA interrupt and reduced the adc sample rate to  +-6khz, but it is still showing the same behavior, Systick is incrementing too fast when DMA is initialized. here are my ADC module and clock configs.

clock.png

adc1.png

adc2.png

yIzumi
Associate II

Hi TDK, thanks for the quick reply.

I tried to slow it down to 6khz but it kept showing the same behavior, i posted my configs of the adc and clock module on my reply to Gwénolé.

yIzumi
Associate II

I found the problem, and as expected, it was a silly one.
I was initializing the ADC dma and telling it to store on a 6-position buffer, but the buffer was declared with 4 positions. So I guess the DMA never finished the conversion? Anyway, now it works fine. But I do think that the fast sampling time was making it worse, so really, thanks for the useful replies.