AnsweredAssumed Answered

6 step PWM on STM8L15x

Question asked by petushin.kirill on Jun 10, 2011
Hey!
I'm trying to make sensorless BLDC control unit on STM8L15xxx MCU.
High-side switches of drive circuit are opened by logical "1", and low-side - by logical "0".
So I need to perform six-step trapezoidal commutation using Timer1.
The problem arises at transition between phase where top or bottom output of channel are active and phase where both top and bottom outputs of same channel must be inactive.
I'm using the algorithm shown below. But i have some problems in the moment of transition between active and inactive phases. It seems like the top output makes an impulse when it already have to be inactive.
Could You advise something for me?

(this code is performed within of interception)

// Disable All PWM Channels
   TIM1->CCER1 &= (uint8_t)(~(TIM1_CCER1_CC1NE|TIM1_CCER1_CC2NE|TIM1_CCER1_CC1E|TIM1_CCER1_CC2E));
   TIM1->CCER2 &= (uint8_t)(~(TIM1_CCER2_CC3NE|TIM1_CCER2_CC3E));

   switch (PWMstep)
   {
     case 1:
   
    TIM1->CCR1H = (uint8_t)(CCR1_V >> 8);
    TIM1->CCR1L = (uint8_t)(CCR1_V);
    
    TIM1->CCR2H = (uint8_t)(0);
    TIM1->CCR2L = (uint8_t)(0);
    
    TIM1->CCR3H = (uint8_t)(TIM1_PERIOD >> 8);
    TIM1->CCR3L = (uint8_t)(TIM1_PERIOD);      
    
    TIM1_CCxCmd(TIM1_Channel_1, ENABLE);
    TIM1_CCxNCmd(TIM1_Channel_2, ENABLE);
    TIM1_CCxCmd(TIM1_Channel_3, ENABLE);          
  break;
  case 2:   
    TIM1->CCR1H = (uint8_t)(CCR1_V >> 8);
    TIM1->CCR1L = (uint8_t)(CCR1_V);
 
    TIM1->CCR2H = (uint8_t)(TIM1_PERIOD >> 8);
    TIM1->CCR2L = (uint8_t)(TIM1_PERIOD);     
 
    TIM1->CCR3H = (uint8_t)(0);
    TIM1->CCR3L = (uint8_t)(0);  

    TIM1_CCxCmd(TIM1_Channel_1, ENABLE);  
    TIM1_CCxCmd(TIM1_Channel_2, ENABLE);
    TIM1_CCxNCmd(TIM1_Channel_3, ENABLE);
... and so on

Preload is not used.

Outcomes