cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger ADC at a specific point during the ON period of PWM in STM32F303ZE?

김형건
Associate

Hello,

I am currently working on sensorless PI control for a BLDC motor, and I am using the STM32F303ZE MCU for this project.

In sensorless BLDC motor control, the motor must transition to the next commutation step 30 electrical degrees after the zero-crossing point (ZCP) of the unenergized phase’s Back EMF (BEMF). Therefore, I need to continuously monitor the BEMF of each phase using the ADC.

For my BLDC motor control strategy, I am implementing a unipolar PWM modulation technique. During the ON period of PWM, I need to sample the BEMF voltage, DC bus voltage, and DC bus current. Specifically, I want the ADC conversion to occur at around 90% of the ON duration of the PWM cycle.

However, since the duty cycle of the PWM is constantly changing due to the PI controller, the ADC must always trigger at the dynamically changing 90% point of the ON period.

My questions:
How can I configure the STM32F303ZE to trigger the ADC conversion at 90% of the ON duration of PWM?
Is it possible to achieve this without CPU intervention, using only register-level configurations (hardware-based solution)?
If register-based configuration is possible, which timer (TIM1 TRGO, TIMx, or any other peripheral) should be used, and how should I configure it?
I would appreciate any guidance, reference materials, or example code that could help me achieve this.
Thank you in advance!

2 REPLIES 2
Kraal
Senior III

Hi,

I think this is doable.
You will need an additional timer that must be able to trig the ADC conversion on the CCn event and optionnaly be a slave of the PWM timer (to ease the synchro).
Set the same ARR value for both timers (make sure they have the same clock source).
Configure the ADC to trig the AD conversions on the additional timer CCn event.
Now, when the PI controller compute the new ON time, set the CCRn register of the additional timer with 90% of that value. You should get what you want this way.

See the reference manual (page 334 for RM0316) to check which timer could fit your application.

Please note that I have not tested what I wrote above, it is just the first idea that came through my mind.

Have a nice day.

> How can I configure the STM32F303ZE to trigger the ADC conversion at 90% of the ON duration of PWM?
Is it possible to achieve this without CPU intervention, using only register-level configurations (hardware-based solution)?

How would the hardware calculate 90%?

So, you calculate it, in the very same routine (PI controler)  where you calculate duty cycle of PWM; and use it in either a spare channel of the timer you are using for the PWM, or a synchronously running other channel, to generate trigger for the ADC (see External triggers for regular channels table in the ADC chapter in RM).

JW