cancel
Showing results for 
Search instead for 
Did you mean: 

When to set TIM1 pwm channels - 3phase drive

Bogdan
Senior
Posted on November 13, 2017 at 20:52

Hello,

I have a  project where a 3phase DC BLDC motor is required to be spined.

For now i have : - 3 hall sensors conected to CH1,2,3 of the TIMER2.

                          - 6 complementary pwms via Timer1

In the Timer2 CC1 handler i read the hall sensors, forming a 'index' value after which i compare with my lookup table

void TIM2_IRQHandler()

{

if (TIM_GetITStatus(TIM2, TIM_IT_CC1) != RESET)

{

TIM_ClearITPendingBit(TIM2, TIM_IT_CC1);

pdata= (GPIO_ReadInputData(GPIOA)& 0x0007);

UH = FORWARD_TABLE[pdata][0];

UL = FORWARD_TABLE[pdata][1];

VH = FORWARD_TABLE[pdata][2];

VL = FORWARD_TABLE[pdata][3];

WH = FORWARD_TABLE[pdata][4];

WL = FORWARD_TABLE[pdata][5];

bellow i set the 6 complementary PWM pins for the TIMER1

}

Do i need to set the timer1 pins in advance for the next position in the TIM2 CC1 IRQ ?  Or i need to set them on the current hall read position?

0 REPLIES 0