cancel
Showing results for 
Search instead for 
Did you mean: 

PWM Complimentory signal is not getting with HAL_TIM_PWM_Start_DMA

thannara123
Associate III

Hello experts 

I am trying to make a PWM signal from DMA , with PWM + complimentory channel
When i use HAL API
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sin_table, 32);
// Here I get the signal as expected
 
But when I Use HAL API
HAL_TIMEx_PWMN_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sin_table, 32);
// It not driving the CH1N channel nothing getting
 
Whats the problem
9 REPLIES 9
Sarra.S
ST Employee

Hello @thannara123

Just start the CH1N with HAL_TIMEx_PWMN_Start()

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

I had also try with HAL_TIMEx_PWMN_Start() but there is no affect to output too. it's like as there is something missing in side that function. 

Sarra.S
ST Employee

Hello, could you share your timer configuration

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

This is my Timer 2 Initial.

 

static void MX_TIM2_Init(void)
{

  /* USER CODE BEGIN TIM2_Init 0 */

  /* USER CODE END TIM2_Init 0 */

  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  TIM_MasterConfigTypeDef sMasterConfig = {0};
  TIM_OC_InitTypeDef sConfigOC = {0};

  /* USER CODE BEGIN TIM2_Init 1 */

  /* USER CODE END TIM2_Init 1 */
  htim2.Instance = TIM2;
  htim2.Init.Prescaler = 639;
  htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim2.Init.Period = 999;
  htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
  if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
  {
    Error_Handler();
  }
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)
  {
    Error_Handler();
  }
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
  {
    Error_Handler();
  }
  sConfigOC.OCMode = TIM_OCMODE_PWM1;
  sConfigOC.Pulse = 0;
  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
  sConfigOC.OCFastMode = TIM_OCFAST_ENABLE;
  if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN TIM2_Init 2 */

  /* USER CODE END TIM2_Init 2 */
  HAL_TIM_MspPostInit(&htim2);

}

 

and I had try to start timer 2 in many way

 

//  HAL_TIMEx_PWMN_Start_DMA(&htim2, TIM_CHANNEL_1, &dsin,360);
  HAL_TIM_Base_Start(&htim2);
//  HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_1, &dsin,360);
//    HAL_TIMEx_PWMN_Start_DMA(&htim2, TIM_CHANNEL_1, &dsin,360);

 

there are only HAL_TIM that it's work fine and HAL_TIMEX is nothing run even the register is not start too.

thannara123
Associate III
 
  HAL_TIM_Base_Start_DMA(&htim2, TIM_CHANNEL_1, &dsin,360);
  HAL_TIMEx_PWMN_Start(&htim2, TIM_CHANNEL_1,);

Try it ,
will work 

that has only HAL_TIM_Base_Start_DMA(&htim2, TIM_CHANNEL_1, &dsin,360); 
without HAL_TIMEx_PWMN_Start(&htim2, TIM_CHANNEL_1,);
it's still work fine.

so HAL_TIMEx_PWMN_Start(&htim2, TIM_CHANNEL_1,); , what 's necessary of it?

thannara123
Associate III

HAL_TIMEx_PWMN_Start(&htim2, TIM_CHANNEL_1,); // It is used to getout the complimentory signal of

 

 

Oh, I got it. A Complementary one is negative PWM used for drive H bridge.

The complementary signal output CH1N must be enabled independently, even without using the CH1 output.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.