cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F413VG TIM1 PWM generation trouble

eidetech
Associate II

I am having trouble getting the TIM1 timer on the STM32F413VG chip to output PWM to pin PE9. My configuration and code in STM32CubeIDE can be seen in the attached images. Have I done something wrong? Every example I have found out there skips TIM1 and goes straight to TIM2, could it be that TIM1 does not support PWM generation, even though it is an option in CubeIDE?

0693W00000HrJccQAF.png0693W00000HrJcXQAV.png0693W00000HrJcNQAV.png

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Should work.

Initialize PE9 as GPIO output and toggle to verify you're actually monitoring that pin.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

7 REPLIES 7

TIM1 and TIM8 are Advanced Timers, you must explicitly enable the PWM outputs. HAL_TIM_PWM_Start()

Show the actual pin and clock initialization code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

Should work.

Initialize PE9 as GPIO output and toggle to verify you're actually monitoring that pin.

If you feel a post has answered your question, please click "Accept as Solution".

Read out and check/post content of TIM and relevant GPIO registers content.

JW

eidetech
Associate II

Thanks a lot for the replies guys. As TDK said, it should work, and it did. The problem was that I am apparently confused with the orientation of the chip. So when I measured the correct pin, I got the expected output :). I assume you guys can tell me the logic here: In the datasheet, the LQFP100 chip is presented like this:

0693W00000HrRuPQAV.pngAs you can see (you guys are probably familiar with this, but I will try to explain my confusion), the chip is presented without any of the orientation markers, nor text that specifies the orientation. Therefore I assumed that the text on the physical chip would match the orientation of the figure, but to my surprise, it is actually rotated 90 degrees CCW.

Would any of you care to explain to me why that is, and where I can find documentation for this in upcoming projects?

Hi,

From the above code, i have used, I am getting output. But from this method how to calculate the PWM frequency can you please suggest me.

AScha.3
Chief III

 the orientation marker on a chip -> is to know, where is pin no. 1 .

here you see all the pin numbers ... too much information ???

If you feel a post has answered your question, please click "Accept as Solution".
TDK
Guru

Marking information is found in the datasheet.

0693W00000WI7pAQAT.png 

With text oriented left to right, pin one is bottom-left.

If you feel a post has answered your question, please click "Accept as Solution".