cancel
Showing results for 
Search instead for 
Did you mean: 

How is the Timer Output Chanel linked to a Pin?

GWood.1
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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
Associate II

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!