cancel
Showing results for 
Search instead for 
Did you mean: 

TIM13 and TIM14 PWM output issues STM32H562

dlewis
Associate II

Hi All,

I have a project that is using the STM32H562. I am having an issue using tim13 and tim14 to generate PWM outputs going to LEDs. The project uses timers tim2, tim3, tim4, tim13, and tim14 for a range of different PWM peripherals. For all of the timer instances that aren't tim13 and tim14, the PWM configures and works as expected, but I am unable to get any PWM output signal on the channels controlled by tim13 and tim14. Neither the autogenerated INIT functions or my application code to update the pulse width value return any errors from the HAL functions, and I can see the value of the registers being updated with the new pulse value, but there is no output on those pins. I have verified to some extent the hardware, because I am able to toggle those LED pins by configuring them as standard GPIO outputs and driving them high to see the LEDs illuminate. Any suggestions or information would be greatly appreciated! I can provide more information upon request. Thanks! 

12 REPLIES 12

Hi CMYL,

In my project I have the pulse set to 0 initially, but it is updated during runtime when the application needs to use the PWM. I have confirmed that the pulse value is correctly being set, but I did not include register values showing that here. All of the 12 or so PWM signals I am using are set to 0 pulse by default and then updated as needed. In one of my comments or post above it should show the functions I created to update the pulse during runtime. This method works for 10 of the 12 PWMs but the 2 mentioned in the post title do not output anything even though the pulse is being set. 

CMYL
ST Employee

Thanks @dlewis 

I will check according to pulse update function.

CMYL
ST Employee

Hi @dlewis 

I started from 0 as pulse period as you suggested, then I changed the periods for TIM13 and TIM14 as follow in accordingly in the while(1).

  MX_GPIO_Init();
  MX_TIM13_Init();
  MX_TIM14_Init();
  /* USER CODE BEGIN 2 */
  HAL_TIM_PWM_Start(&htim13, TIM_CHANNEL_1);
  HAL_TIM_PWM_Start(&htim14, TIM_CHANNEL_1); 
  /* USER CODE END 2 */
  HAL_Delay(4000); /* no output signal as pulse = 0*/
  while (1)
  {
    period1 = (period1 + 100) % 900;
    sConfigOC.Pulse = period1;
    HAL_TIM_PWM_ConfigChannel(&htim13, &sConfigOC, TIM_CHANNEL_1);

    period2 = (period2 + 200)%900;
    sConfigOC.Pulse = period2;
    HAL_TIM_PWM_ConfigChannel(&htim14, &sConfigOC, TIM_CHANNEL_1;
     
    HAL_Delay(3000); /* delay to follow changes*/
  } /* while 1*/
  /* USER CODE END 3 */
}

 I can see that the wide of the pulse is changing using a logic analyzer. 

CMYL_1-1746038326018.png

Can you add the other timers and check if there is any issues?

Best regards