cancel
Showing results for 
Search instead for 
Did you mean: 

Make PWM from internal clock in STM32F407G

KUSAGI
Associate II

Hi everyone,

i am trying to make PWM from internal clock. i use TIM4 with out put is pin PD12.

i just put the code bellow in INT VOID(MAIN)

HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1);

But it doesn't work. 

Can someone help me explain?

5 REPLIES 5
TDK
Guru

You need to initialize the pins and timer first. Use STM32CubeMX to generate the code for you, or look at examples in the CubeF4 repository.

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

Thanks you for reply,

i initialize the pin already. i was follow on youtube how to make pwm. and did base on that. but not effect

https://www.youtube.com/watch?v=vDvbO_BAYvc&t=176s

i don't know what happen!

KUSAGI
Associate II

can you give me some examples?

KUSAGI
Associate II

initialize pin timer

0693W000003OZknQAG.png

TDK
Guru

> can you give me some examples?

Here is one example:

https://github.com/STMicroelectronics/STM32CubeF4/blob/b5abca20c9676b04f8d2885a668a9b653ee65705/Projects/STM32446E_EVAL/Examples/TIM/TIM_PWMOutput/Src/main.c

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