cancel
Showing results for 
Search instead for 
Did you mean: 

trigger adc after counter is reached

Posted on March 21, 2016 at 23:50

Hello there,

I was wondering either in STM32F4 it is possible, to get a similar functionality to C2000 one, that can trigger an ADC conversion after certain counter valueon a timer is reached, like here:

https://www.dropbox.com/s/d6lonep1m3i5x4d/Zrzut%20ekranu%202016-03-21%2023.48.06.png?dl=0

(point CA, middle).

In stm34f4 I am using center aligned pwm mode. I can trigger ADC each time timer starts counting up/down or both. But I need to trigger the adc when the counter is halfway down or up. Is there a way to do this?

I would appreciate all help.

#timer #adc #synchronization
26 REPLIES 26
Posted on March 23, 2016 at 16:57

But can a channel from another timer be slaved to this channel? So lets say TIM1 OC1 triggers interrupt and it makes TIM5 OC3 channel start counting?

The clocks on the chip are synchronous. You could set up another timer that gets reset by the master at it's update, you set the slave timer to count at a comparable rate, and use that to manage the phase angle of the trigger. You have a common understanding of what zero is.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Senior II
Posted on March 23, 2016 at 18:43

Hi Bremen, 

In fact those are the capture/compare events (occurs when there is a match between CCRx and counter value) and I am talking about the update event ( which occurs on the counter overflow). So if you take a look to the table of ADC external trigger , you find both ( TIMx_CHx_envent and TIMx-TRGO event ). The second will serve your need.

Please, try to apply the recommendations already mentioned and come back if it is not OK for you.

-Hannibal-

Posted on March 23, 2016 at 18:48

Ok, I get it now. Ill try it tommorow and post back. Thank you very much.

Posted on March 24, 2016 at 08:27

I am trying to make the configuration now. I am trying to enable TIM1 trgo to trigger and injected channel conversion, but It doesnt seem to work (injected channel conversion interrupt is not triggered). Are there any other considerations taht has to be taken when using injected channel?

Walid FTITI_O
Senior II
Posted on March 24, 2016 at 15:14

Hi Bremen,

Please, try to share your code (Timer configuration , ADC configuration ..clock ..) to figure out what you have missed.

-Hannibal-

Posted on March 25, 2016 at 08:02

I think I got it now, I had some config errors and now its ok. Thank you very much for help guys, your help is priceless.

Walid FTITI_O
Senior II
Posted on March 25, 2016 at 11:29

Hi Bremen,

It's nice to hear that. Keep up the good work.

-Hannibal-