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! 

16 REPLIES 16

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

 

Hi @CMYL 

I tried using a similar method to you by ignoring the rtos and manually controlling the PWM of TIM13 and TIM14 in the main while(). This successfully demonstrated PWM for the 2 problematic pins as visible on the connected RGBW LED on our pcb. This seems to be consistent to me with the fact that those 2 pins could be toggled as GPIO outputs to turn on the LEDs, but the issue still persists where those 2 pins alone do not output any PWM when being used in an application where all of the other PWM peripherals are also being used. 

I am going to try manually adjusting the order of timer configurations and also give tim13 and tim14 an initial pulse length using the IOC gui to see if that makes a difference for some reason. 

Any other advice or feedback would be appreciated! I can share more of my code if that would help debug as well. Thanks!

Sarra.S
ST Employee

Hello @dlewisI tested the PWM output of all five timers simultaneously using a Nucleo-H563, and everything appears to be functioning correctly on my end:

SarraS_0-1747316010099.png

When I tried using only TIM13 and TIM14 outputs, I encountered an issue where only the second timer initiated with HAL_TIM_PWM_Start was generating an output. However, rearranging the order of instructions—starting PWM TIM14 before TIM13—resolved the problem!

SarraS_1-1747316700473.png

 

then, when I reverted to the original order (starting TIM13 before TIM14) it continued to work, which is quite puzzling!

It would be interesting if you could try this on your end! while I try to further investigate the order behavior. 

Thank you

 

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.

Hi @Sarra.S 

I tried rearranging the order of which HAL_TIM_PWM_Start is used for each instance/channel and this did not seem to make any difference in results for me.

waclawek.jan
Super User

Hi @dlewis ,

at this point, as it appears to be hard to reproduce the problem, you may want to prepare a minimal but complete compilable example exhibiting the problem, and post it together with the binary (.elf).

JW