cancel
Showing results for 
Search instead for 
Did you mean: 

Can we latch encoder timer synchronized current measurement? (STM32H5)

yang2
Associate III

Dear All,
I am developing a motor control system(FOC) with STM32H5.
In the FOC process, while completing the ADC conversion for current measurement, it enters the ADC interrupt, where I read the TIM2 counter(for Encoder interface) to obtain rotor angle information.

What I’m considering is that since the motor is rotating, reading the TIM2 value after ADC converts(current measurement)  may not ensure that they are synchronized (althought the time difference is minimal).

 

Does STM32H5 have any features that can trigger TIM2 to latch the counter simultaneously when sampling the current?

Best Regards,

 

2 REPLIES 2

If the ADC is triggered from a timer, you can use TRGO from that timer as TRGI into TIM2 (by selecting it in as appropriate ITRx in TIM2_SMCR.TS) and then use that to trigger Capture on TIM2_CH3 or TIM2_CH4 by setting TIM2_CCMR2.CCxS to 0b11 to capture upon trigger (TRC - that's ouput signal of the trigger selector mux).

JW

Roger SHIVELY
ST Employee

Hello @yang2 

 

This post has been escalated to the ST Online Support Team for additional assistance. 

 

We'll contact you directly.

 

Regards,

Roger