cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate TRGO exactly at the midpoint of PWM ON-time in Center-Aligned PWM Mode 2?

김형건
Associate II

_0-1747150431170.png

_1-1747151036087.png

Hello,

I'm using STM32F103RB and have configured TIM1 Channel 1/2/3 as PWM Generation CH1/2/3 in Center-Aligned Mode 2.

The clock source is internal (HSI = 8 MHz), and the APB2 timer clock is set to 64 MHz.

I configured PSC = 1 and ARR = 1599 to produce a 20 kHz PWM.

My goal is to trigger ADC at the exact midpoint of the PWM ON-time, which in Center-Aligned PWM Mode 2 should correspond to the point where CNT reaches ARR.

To do this, I tried setting Trigger Event Selection (TRGO) to Update Event, but I suspect that the update event happens both when CNT = 0 and CNT = ARR.

If so, it wouldn't guarantee that the trigger is generated only at the center of the ON pulse, which is my intended sampling point for BEMF.

My questions are:
Does Update Event in Center-Aligned Mode 2 occur both at CNT = 0 and CNT = ARR?

If so, what is the best way to configure TRGO so that ADC is triggered only when CNT = ARR, i.e., the center of PWM ON-time?

Would using Output Compare (OCxREF) as the TRGO source and setting CCRx = ARR be a better approach?

Any clarification would be very helpful.
Thank you!

2 REPLIES 2
TDK
Guru

Didn't you just ask this?

trigger ADC exactly at midpoint of PWM ON time in ... - STMicroelectronics Community

If you feel a post has answered your question, please click "Accept as Solution".
김형건
Associate II

I've re-arranged and posted my questions. I've changed some of my settings and re-arranged my curiosity (of course it hasn't changed much...).