2025-09-30 10:20 PM
Hi Sir,
I tried to refer to the PWM example:
~\stm32cubeh7-v1-12-0\STM32Cube_FW_H7_V1.12.0\Projects\STM32H743I-EVAL\Examples\TIM\TIM_PWMOutput
I see the four GPIO pins are initialized:
And I see the four PWM channels are setup:
But I can't find the code where each GPIO pin is bound to each PWM channel or the ISR where each GPIO is toggled whenever a PWM channel interrupt occurs.
Please advise. Thanks.
Jimmy
Solved! Go to Solution.
2025-10-01 12:48 AM
you probably meant the AF mapping table in Datasheet, rather than in Reference Manual.
As said above, read the Datasheet for your STM32, and the GPIO chapter in Reference Manual.
Unfortunately, CubeMX generated some "magic values" for you and Cube/HAL hides rest of the details, so it's not visible from the code you presented, how exactly are the GPIO set. Fortunately, Cube/HAL is open source, so you can read it yourself and/or single-step through it, while observing the GPIO registers, to get a grip on what's going on.
JW
2025-10-01 12:31 AM
Hello,
In next time please share the code and use </> instead of sharing screenshots of the code.
I’m not sure I understood the question but .Alternate member of the GPIO structure is the one responsible of linking the timer functions or any other peripheral functions to the GPIOs.
You need to refer to the reference manual of the product and there is a table showing tha mapping of these alternate functions on the GPIOs.
2025-10-01 12:48 AM
you probably meant the AF mapping table in Datasheet, rather than in Reference Manual.
As said above, read the Datasheet for your STM32, and the GPIO chapter in Reference Manual.
Unfortunately, CubeMX generated some "magic values" for you and Cube/HAL hides rest of the details, so it's not visible from the code you presented, how exactly are the GPIO set. Fortunately, Cube/HAL is open source, so you can read it yourself and/or single-step through it, while observing the GPIO registers, to get a grip on what's going on.
JW
2025-10-01 1:27 AM
It seems that the alternate function is specified here when configuring a GPIO:
Thanks for the information.
Jimmy