2014-11-20 03:07 AM
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¤tviews=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
2014-11-20 06:19 AM
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,000Conversely 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....2014-11-20 07:22 AM
ok thanks,
and to read the converted value?2014-11-20 07:47 AM
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.2017-10-12 02:11 PM
DEAD LINK from top post
https://community.st.com/0D50X00009XkibiSAB