Skip to main content
GWood.1
Associate II
December 29, 2020
Solved

How is the Timer Output Chanel linked to a Pin?

  • December 29, 2020
  • 2 replies
  • 1483 views

I have been following along with https://www.youtube.com/watch?v=-AFCcfzK9xc

and I can see that each change made in CubeMX produces changes in my generated code in main.c

However, I cannot find any generated code which links the Timer Output Channel 1 to my GPIO Pin PA5. Is it being saved somewhere else, or is it being saved in some obscure way that I've missed?

This topic has been closed for replies.
Best answer by waclawek.jan

The whole Cube/CubeMX combo is obscure.

Normally, this "assignment" is through setting value corresponding to given peripheral (see table in Datasheet) into the field appropriate for given pin in respective GPIOx_AFR register (see GPIO chapter in RM).

So, this is GPIO-setup related.

I don't Cube, but AFAIK they like to put these things into a "MSP" callback, to be called from the timer initialization function, probably in a separate .c file (stm32XXXxx_hal_msp.c ?)

JW

PS. You've surely familiar with the Cube/CubeMX documentation:

0693W000006H5byQAC.png

2 replies

waclawek.jan
waclawek.janBest answer
Super User
December 29, 2020

The whole Cube/CubeMX combo is obscure.

Normally, this "assignment" is through setting value corresponding to given peripheral (see table in Datasheet) into the field appropriate for given pin in respective GPIOx_AFR register (see GPIO chapter in RM).

So, this is GPIO-setup related.

I don't Cube, but AFAIK they like to put these things into a "MSP" callback, to be called from the timer initialization function, probably in a separate .c file (stm32XXXxx_hal_msp.c ?)

JW

PS. You've surely familiar with the Cube/CubeMX documentation:

0693W000006H5byQAC.png

GWood.1
GWood.1Author
Associate II
December 29, 2020

Excellent. You were correct, it is set up in stm32f4xx_hal_msp.c

I find it a little odd that most of the user defined setup is in main.c, and some bits in the _hal_msp file.

However, I am only just starting out with this, so I can't be critical!

Also, thanks for the reference to the HAL drivers documentation, I need to refer to it more!