cancel
Showing results for 
Search instead for 
Did you mean: 

Timer4 trigger for ADC

stuart239955
Associate II
Posted on June 15, 2011 at 10:15

Hi,

Using STM32F103.

I want to use the external trigger mode of the ADC to start a regular group of channels (in dual, simultaneous mode) via the TIM4 CC4 Event.

The examples that ST provide illustrate using TIM1 CC1 event using a pwm OUTPUT channel to trigger the ADC.

I wish to trigger my regular channels via INPUT capture on TIM4 channel4. Is this possible?

The documentation seems to suggest so.

I have tried using a basic example, but to no avail. The TIMER4 input capture event occurs, but doesn't trigger the ADC. I can manually trigger the ADC via software, so am not sure what could be wrong.

Is there some trick that I am missing here? Is there an example someone could send me?

Also note that I am doing a full remapping TIMER 4 pins.

I'm using my own code - not using the library, so have not got any code to fully illustrate this yet, sorry.

Any ideas would be most welcome.

Thanks,

#adc-trig-in-dual-mode #poor-quality-of-documentation
24 REPLIES 24
Posted on May 24, 2015 at 18:37

Ok, it's triggering the samples at 200 KHz (200000 Samples per second). The comments reflect the behaviour I expect, these could be confirmed with an oscilloscope.

The buffer holds 400 samples, and interrupts at the half and end points. ie every 200 samples, and thus with a rate of 1 KHz into the handler. The math here is not complex, you could make the buffer bigger to reduce the interrupt rate.

You'll need to config the CPU/AHB/APB clocks to get a clean integer division of you sample rate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bougarech
Associate II
Posted on May 24, 2015 at 20:28

is it possible to modify the interrupt handler to get it more faster than 1Khz??

Posted on May 24, 2015 at 22:46

One could make the buffer smaller. Increasing the interrupt rate is probably not particularly desirable as you'll just burn instructions less efficiently. The 1 KHz rate was chosen as it's easy to scope.

The reason the buffer is split in two (ping-pong) is that the DMA continues in the background, and it's desirable to operate on data that's not going to change underneath you. If you plan on recording data to a file, you want the buffer to be large enough that the write operation is most efficient, ie some power of two greater than 512, and ideally at least a cluster length, or 32KB

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
puneethj
Associate II
Posted on August 28, 2015 at 10:26

Hello Every body, Can some one let me know how to use ADC Hardware Trigger? Thank You

Posted on August 28, 2015 at 20:22

Let's try to keep this in [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/ADC%20External%20Trigger&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx&currentviews=20]your own thread rather than off-topic this one (STM32F1 TIM4 Triggering ADC)

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