Skip to main content
Associate
January 6, 2024
Question

STM32F334 ADC Jumps

Hello,

 

I am using a STM32F334 for a project where I am reading several analog channels, specifically connected to thermistors. I am using DMA to read the analog channels and also sending this data out on UART via DMA. 

 

I am seeing some weird jumps in the data, which also correspond with longer than normal intervals between sending UART data.

 

It seems like only analog data is doing this and I'm wondering why. Does it maybe have something to do with DMA? I have different priorities set for the DMA streams in the STM32Cube project configuration. 

 

I am sampling the internal temp sensor channel, Vref, and Vbat channels, if that is useful. I have the longest sampling interval set as well. 

 

Any help or tips appreciated. 

 

 

This topic has been closed for replies.

8 replies

TDK
January 6, 2024

It seems like you are not sending out in regular intervals, so you are missing out on data when the interval is longer than normal. This would explain your plots.

What is the cause for delays in sending UART data? Has to be something in your code slowing the process down, or causing delays.

"If you feel a post has answered your question, please click ""Accept as Solution""."
jlsAuthor
Associate
January 6, 2024

Thanks for your reply. 

 

I'm not sure why there is this intermittent longer interval in UART sending. I just have one main loop with the same calculations running and then the UART DMA transmit is sending every 150 loop iterations. 

 

I also have another plot from the same data collection which is showing loop speed (see attached) and internal MCU temp. 

 

I wonder why I don't really see this jumpiness in those plots, but only in the thermistor connected ADC channels. 

 

Any other thoughts based on this? 

 

Thanks

TDK
January 6, 2024

Loop speed and mcu temp look to be mostly constant. I don't think the jump would show up on those plots.

Send a timer value such as HAL_GetTick with each UART burst and plot it, I'm sure the problem will be evident there.

It's also possible the thermistor data is just real. Is something happening every 10-15 seconds? Temperature going from +13 to -13 over 2 minutes is weird. Is this in a refrigerator or something?

"If you feel a post has answered your question, please click ""Accept as Solution""."
jlsAuthor
Associate
January 6, 2024

Hello, thanks again. I am sending 48 bytes of data every 150 iterations of the loop. This is at 115,200 baud rate. This should take about 3.3 ms for the data to be sent out. Since my loop speed seems to be around 5000 Hz, I should have around 30ms between each send command. I am not checking the return values from the HAL send functions but I can try doing that. The only interrupts I have enabled are the ADC conversion complete interrupts. So I think nothing else should be affecting the loop running continuously except for possibly that. 

 

I will try running the timer experiment later tonight where I send out a timer value on the UART data burst. I keep thinking there might be some conflict with DMA between ADC and UART, but I have different priorities set for the two of them and have tried a lot of different settings. I should hopefully get some more insight with a few more experiments though. I'll share what I find. 

 

Let me know if anything else comes to mind.

 

Thanks. 

TDK
January 6, 2024

> I keep thinking there might be some conflict with DMA between ADC and UART

Why? Think you're chasing the wrong thing here. UART at 115200 baud isn't taxing even 1% of the DMA bandwidth. Priorities won't matter--DMA can service everything quickly enough.

"If you feel a post has answered your question, please click ""Accept as Solution""."
jlsAuthor
Associate
January 17, 2024

I changed some of the priorities of the DMA and interrupts and restructured the code a little bit and was able to get the problem to go away.