cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f303k8 Unable to coordinate multimode ADC and UART transmission

kl4971tse
Associate II
Posted on November 21, 2016 at 02:04

Hello!

I am currently trying to program on the stm32f303k8 to be able to read ADC values from 2 channels, average the values, and transmit the values through UART while also periodically rotating 3 pins for mux and 3 pins for LEDs. I've tried using either continuous mode or the TIM2 timing for the ADC conversion from the STM32mxcube software. What I believe is happening is that the ADC buffer is being overwritten before they can be placed into a transmit buffer. Is there any way I can temporarily pause the continuous ADC sampling to be able to save the values before another trigger occurs? I've tried dropping the TIM2 down to 100 Hz, but it still doesn't solve the problem.

Thank you for your help!

 
3 REPLIES 3
Posted on November 21, 2016 at 03:29

Can't help you with the HAL, but the way to deal with this on the STM32 is to double the buffer size, and use the DMA HT and TC interrupts to work on the half of the buffer than isn't changing underneath you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AvaTar
Lead
Posted on November 21, 2016 at 08:10

> I've tried using either continuous mode or the TIM2 timing for the ADC conversion from the STM32mxcube software. dropping the TIM2 down to 100 Hz, but it still doesn't solve the problem.

 

Do you call UART output routines (or

printf()

) from the ADC interrupt ?

You need to decouple both. If sending one char takes longer than you sampling period (

most probably the case), you are ''doomed''.

Neither do I Cube, though ...

kl4971tse
Associate II
Posted on November 22, 2016 at 03:09

Thanks for the idea and the quick response! Doubling the buffer worked, but only if I disable my averaging function. I'll try to rework the function to be less computationally expensive.