2013-10-11 07:46 AM
For example i want to use TIM9_CC2 event trigger. I don't understand when does this event happens & triggers the ADC to start sampling.
I thought one controls it with TIM9->CCR2 value, but thought wrong - unless it's 0 ADC doesnt seem to be triggered at all.2013-10-11 10:19 AM
You'd have to set up a valid time base, and channel (like a PWM mode), in PWM zero would be OFF. You'd need to set the ADC to trigger on a rising/falling edge.
While you don't need to output a signal to a pin for the timer, it might help you visualize the signal, and consider if it is appropriate. Also you don't want to be doing continuous conversions.[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&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=787]Example using timer here2013-10-14 12:52 AM
> Also you don't want to be doing continuous conversions.
Why not? In my current configuration i have 3, 4 channels , single-sampled one after the other. But currently this is without timer, and i need to add timer trigger into this. Won't timer trigger just start the first conversion, with the rest cascading?2013-10-14 01:19 AM
I think i need to change my question :
If you ignore all the setup and config stuff, when is the TIM9_CC2 event get generated? Is it on the update/write of CCR2, or when the Timer 9 counted to the value loaded in CCR2 , or something else ;)2013-10-14 04:43 AM
Continuous implies that it's uncontrolled and goes on without any triggering. Kinda defeats the point of triggering it.
CC2 means it's looking at Channel 2, if you select RISING edge on a PWM mode signal it's going to trigger at Time Zero (Update), as long as CCR2>0 then you'll get some pulse. Look at the signal on the scope. If you want to trigger on the FALLING edge you could use multiple timer channels to the relative phase of CCRx2013-10-14 05:07 AM
Yes, I got wrong the continuous . the number of conversions /channels is what i wanted > 1.
2013-10-14 07:30 AM
I've modified what i have to use the TIM9_TRGO, as per example you've given.
That seems to generate me the right sampling rate - at the set timer period, still to check more. I don't know what i thought of CC2 event now at all. Don't know how I would set it up: Ideally, i wanted this timer to run at higher rate with CC2 allowing me (I thought) to do slower sampling trigger to ADC. e.g: want timer to run at 400Hz say, and also, use it to trigger my ADC sampling at 100Hz But unless I install CCR2 isr and manually/software increment CCR2 (CCR2 += N, timer in upmode ) and also trigger adc software conversion, .... I dont' see how else I can do it.2013-10-14 07:54 AM
Yeah, I'm not sure where you're going with that. The different TIM channels would permit you to sample at different angles/phase of say a motor. Or trigger something externally with one channel, and measure N milliseconds later with another.
Yes, you could chase the CCR setting in an interrupt, but that tends to increase the work load. You could decimate readings using DMA, either to oversample, and interrupt via TC/HT, or collect multiple samples and process them at a slower periodicity.2013-10-14 08:38 AM
clive1 , thanks for help.
I will go with higher timer rate, as in the end i will have to decimate anyway. Just did not want to set that rate and tie up (without reconfiguring it later) the timer to it ;)