cancel
Showing results for 
Search instead for 
Did you mean: 

ADC trigger on timer update

alexpabouct9
Associate II
Posted on August 27, 2013 at 11:24

Hello,

I'm currently working on a brushless motor control application and i'm in the process of implementing the current measuring of the three phases. In order to do so, I need to synchronise the ADC sampling with the PWM outputs in order to sample at the center of the PWM outputs (center aligned 2 mode).

Unfortunately cannot find a simple solution. From the datasheet i see that the ADC can be trigger by either the CC1-4 timer interrupts or the TRGO interrupt. However, from what i've read, the interrupt that that the ADC needs to trigger off of is the timer update interrupt (which is not in the list of available ADC triggers external triggers).

Am i understanding this correctly? I was expecting a straightforward solution as this is a common problem in any motor control application, which is one of the mains features of the advanced timers.

Thanks,

Alex

#stm3-adc-trigger
23 REPLIES 23

200 samples collected at 200 KHz (5us) will take 1ms (1 KHz)

Toggling a pin every 1ms (1 KHz) results in a PERIOD of 2ms (500 Hz)

  1. void DMA2_Stream0_IRQHandler(void) // Called at 1 KHz for 200 KHz sample rate, LED Toggles at 500 Hz

500ms is a timing you've pulled out of the air

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

Thank you @Community member​ 

Well, if I use a pwm timer whose 50% duty, does it mean that half complete callback is only High or Low state?

The TIM triggers the ADC, the ADC EOC triggers the DMA

The DMA generates an interrupt when it's buffer reaches its half way point, and at the end point

HT - HALF TRANSFER

TC - TRANSFER COMPLETE

The phase/duty of the TIM isn't consequential here. The ADC triggers on the leading edge, ie CNT==0 for UPDATE, or CNT==CCR1 for CC1

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

Hımm.

Well, to measure the adc value according to ON/OFF state of that PWM, must the adc be trigged by another TIM?