cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering the adc in center of PWM

IDavo.1
Associate II

Hi Guys,

I did lots of searches but find part of my answer. I'm using STM32F103C8T6 and I want to start voltage measurement by ADC (configured at scan mode and DMA) at the center of my PWM signal generated by TIM1 CC2. On ADC I've set EXTSEL[2..0] = 111 and EXTTRIG = 1 and on Update event by setting SWSTART my ADC starts conversion. Some questions

1) So far it's doing measurement but since I don't have an oscilloscope, I can not confirm if it's working properly or not.

2) Is this the best solution for this purpose or not? If so, why nobody else is using this interrupt and instead using an auxiliary TIM and it's TRGO interrupt is suggested?

3) With this, is my conversion sync with my TIM1 update or not?

4) Isn't better that I use discontinuous mode instead of continuous mode and trig my ADC right when I want it?

0693W000001sAOtQAM.jpg

1 REPLY 1
TDK
Guru

> Is this the best solution for this purpose or not? If so, why nobody else is using this interrupt and instead using an auxiliary TIM and it's TRGO interrupt is suggested?

You haven't really said what your purpose is, but if you need to trigger in the middle of the pulse, seems like a fine solution.

> With this, is my conversion sync with my TIM1 update or not?

Using code within an IRQ to start the ADC conversion means there will be some lag between the update event and the actual start of the conversion. The amount of lag can be variable depending on where the processor is and what other interrupts happen. Using TRGO instead reduces this delay and eliminates the variability.

Update event in center-counting mode happens on both the high (CNT=ARR) and low (CNT=0) of the counter.

If you feel a post has answered your question, please click "Accept as Solution".