cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 DISC - ADC DMA TIM

pano
Associate II
Posted on November 20, 2014 at 12:07

Hi,

I'm a noob but I need to convert two analog signals with a command timer. I have found a code from [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/stm32f207%20ADC%2BTIMER%2BDMA%20%20Poor%20Peripheral%20Library%20Examples&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=3210]this thread. Two answers: 1) how to read the converted value from the main fuction?

ADCDualConvertedValues

is a vector of 800 elements 2) about frequency of the timer: TIM_TimeBaseStructure.TIM_Period = (84000000 / 200000) - 1; 84M/200k = 4...... where 200kHz is from? thanks #adc-dma-tim-dualmode
4 REPLIES 4
Posted on November 20, 2014 at 15:19

There's this relationship between period and frequency, an 84 MHz clock has 84000000 cycles per second, a 200 KHz clock has 200000 cycles per second. The period of ONE 200 KHz cycle contains 420 cycles of the 84 MHz clock.

84,000,000 / 420 = 200,000

Conversely 84,000,000 / 200,000 = 420, and thus the circle completes.

To generate a trigger at a 200 KHz rate, it must occur every 420 cycles on the 84 MHz which is clocking the timer....
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pano
Associate II
Posted on November 20, 2014 at 16:22

ok thanks,

and to read the converted value?
Posted on November 20, 2014 at 16:47

The data is collected in the array, the DMA HT/TC are used as conversion complete signals. The example is for illustration, in the real world you'd likely have your own OS/RTOS code, or whatever, signal to other tasks/processes that the data is ready, or process the sample set in the interrupt.

The buffer is large so that the interrupt loading is reduced. The buffer in two halves so that one half can be processed whilst the DMA fills/overwrites the next half in the background.

If you want to poll in the main() loop, perhaps you should think a bit about what/how to solve your problem.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 12, 2017 at 23:11

DEAD LINK from top post 

https://community.st.com/0D50X00009XkibiSAB

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..