cancel
Showing results for 
Search instead for 
Did you mean: 

trigger ADC exactly at midpoint of PWM ON time in Center-Aligned PWM Mode 2 (TIM1)?

김형건
Associate II

_0-1747148083376.png

(I'm using NUCLEO-F103RB)

Hello,

I'm currently working on a BLDC motor control project using STM32CubeMX and STM32CubeIDE with STM32 TIM1 peripheral.

I have configured TIM1 in Center-Aligned PWM Mode 2, with:

Prescaler = 3

ARR = 899

So, PWM frequency is 10kHz (from a 72MHz system clock).

In this mode, since the counter counts up and down between 0 and ARR, the counter reaching ARR marks the exact midpoint of the PWM ON time.
I would like to trigger an ADC conversion exactly at that point (i.e., at 50% of the ON time).

To do this, I thought of using TRGO = Update Event, since the update event happens when CNT = ARR in Center-Aligned Mode 2.
However, I am not fully sure if this is guaranteed to occur at that midpoint and whether it's the most precise method.

:question_mark:My questions are:
Is TRGO = Update Event guaranteed to occur exactly when CNT = ARR in Center-Aligned Mode 2?

Is this the best practice to trigger ADC at the center of the PWM ON duration?

If not, is there a more accurate or recommended method?

Any insight or clarification would be greatly appreciated.
Thank you in advance!

1 REPLY 1

Update event occurs both on CNT=0 and CNT=ARR.

If you want trigger only upon CNT=ARR, set one channel to CCRx=ARR+1 and trigger on that.

Note, that there may be a delay between the Compare event and ADC trigger, due to resynchronization if the timer is at a different bus than ADC (or maybe even if it's on the same bus). Also note, that ADC trigger starts the sampling process, the ADC conversion start is further delayed by the sampling time.

What's the reason to use particularly Center-Aligned Mode 2?

JW