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 22, 2016 at 00:59

If you have a spare channel in your timer, and that associates with one of the ADC triggers, then you should be able to set the CCR for the desired count, and that should fire each time it passes.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on March 22, 2016 at 07:15

Thank you for help. I dont have one but i will try to get one.

Posted on March 22, 2016 at 08:18

But is there really no way to make the counter count like this maybe?

https://www.dropbox.com/s/iw9gcw9kplbkg8n/Zrzut%20ekranu%202016-03-22%2008.18.08.png?dl=0

Posted on March 22, 2016 at 11:06

I thought that is how pwm centred worked, but not really a timer mode or function I've got much use for.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on March 22, 2016 at 11:50

I thought this as well! But the counter overflow interrupts are generated at the end of pulses...

Posted on March 22, 2016 at 14:09

Ok, but doesn't the timer provide an underflow/overflow indicator so you know which way it was counting?

I suspect you'll need to do some evaluation of what the counter is actually doing.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on March 22, 2016 at 14:23

In center aligned pwm mode 3 I can generate interrupts each timer counter starts counting up and down. So it looks like this:

[[this link/image has been flagged as malicious by our security scan software and has been deleted]]

With RED color i have drawn the counters levels. Red dots are interrupts. As you see I can generate OC interrupts only at the edges, not in the middle, because the counter doesnt stop/ start in the middle...

Posted on March 22, 2016 at 16:11

Is there a way to change this behaviour to get interrupts in the middle so they can fire ADC?

Posted on March 22, 2016 at 16:43

Sorry, I don't know...

The Update should fire at CNT=0

The Up/Down counter should go  22, 23, 24, 23, 22, .. In which case I'd suspect setting CCR to 24 would have the channel fire at the peak value.

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