cancel
Showing results for 
Search instead for 
Did you mean: 

synchronize ADC at the middle of the up-down counter

VidhiPa
Associate II

Hi

How to synchronize ADC triggering at the peak of the up-down counter ?

ADC1 is triggered using TIM1 trigger out event, and TIM1 has center counter mode as aligned mode3. 

Thank you in advance !

5 REPLIES 5
Sarra.S
ST Employee

Hello @VidhiPa

Configure the TIM1 trigger event as an Update event and counter mode as center-aligned mode 3 

Configure the ADC external trigger source as TIM1 trigger out event. 

Also, could you specify which board are you using? 

Thank you!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Sarra, 

Thank you for replying, that is what I have done and I have the trigger event but at the start of the ARR value, I would like to have the trigger at ARR, which would be the midpoint of up down counter as shown in the below image. 

VidhiPa_0-1699454081061.png

 

I am working with STM32G431. 

Sarra.S
ST Employee

oh, I see, thank you for the explanation,

Taking into account that you are using center-aligned mode, which alalternates between counting up (0 -> ARR) and counting down (ARR-> 0) to make a period, once the counter reaches the ARR, you trig the ADC. To do that you should interconnect the TRGO signal of your timer to the ADCx that you want to use for conversion using EXTSEL in the ADC_CFGR register.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

I have settings as below:

with the settings of ADC trigger as below, I have connected TIM1 to ADC1 using TRGO2.

hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T1_TRGO2;

But now the question is how do i set the TIM1 in a way that can give me trigger as explained in above post. I have 3 channels of TIM1 generating 3 PWMs. Channel 4, 5 and 6 are not being used. 

VidhiPa
Associate II

I am not using ADC in injected mode  but in scan conversion mode.