AnsweredAssumed Answered

Generate a clear on/off PWM problem

Question asked by jung.julian on Aug 22, 2016
Latest reply on Aug 23, 2016 by FTITI.Walid
Hello

I have the necessity to generate a PWM out of a pin that stays active for 50us and then goes 0 regularly. In the attachment you see what I want to achieve.
As you can see between some PWM the pin voltage level doesn't reach zero properly. Do anyone of you had similar experience? Any Idea how I can fix it?

Here the function that controls the pin:

  void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  {
    if (htim->Instance==TIM3){
      
      if(PWM_Status == 1){
        PWM_Status = 0;
         
        //Stop PWM
        HAL_TIM_PWM_Stop(&htim15, TIM_CHANNEL_2);
         
        // Deinit PWMs
        HAL_TIM_PWM_DeInit(&htim15); 
         
        // GPIO init
        my_GPIO_Init();
         
        // Reset pin
        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_RESET);
        
       
      }
      else if(PWM_Status == 0){
         PWM_Status = 1;
         
         //Deinit GPIO
         HAL_GPIO_DeInit(GPIOB, GPIO_PIN_15);  
                  
         //Init PWM
         MX_TIM15_Init();
            
        //Start PWM 
        HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_2);
      }      
    }
  }
/* USER CODE END 0 */

I appreciate any suggestion! Thank you in advance.
- Julian

Attachments

Outcomes