2016-11-20 05:04 PM
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!2016-11-20 06:29 PM
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.
2016-11-20 11:10 PM
> 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 ...2016-11-21 06:09 PM
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.