cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F051R8T6 GPIOC Alternate Function / TIM3_CH3 on PC8

AWill.281
Associate

Hello,

I have tried to set the brightness of the blue LED on the STM32F0DISCOVERY via TIM3, not using the HAL or LL driver, but writing the appropriate registers directly, with no sucess.

The peripheral register view shows that any write to GPIOC_AFRH or GPIOC_AFRL has no effect. After further research, it seems like this register doesn't exist at all.

To better understand the situation, I used CubeMX to set up TIM3 channel 3 in PWM mode. The default pin for this function is PB0, but CubeMX shows PC8 as an alternative pin that can be used for PWM output. This and the pinout table found in the datasheet shows that TIM3_CH3 can be mapped to PC8 (with no indication of any model-specific limitations).

In contrast, on page 148 of RM0091 it is stated that

Ports A and B also have [...] two 32-bit alternate function selection registers (GPIOx_AFRH and GPIOx_AFRL). On STM32F07x and STM32F09x devices, also ports C, D and E have two 32-bit alternate function selection registers (GPIOx_AFRH and GPIOx_AFRL).

This suggests that PC8 cannot be used for TIM3_CH3 on STM32F051x controllers.

Is there any resource I have missed that clearly shows which alternate functions are possible on which ports? Should I use the alternate function tables from the datasheet as a definite source of truth? In conclusion, may I assume that CubeMX does show alternate functions on pins that aren't actually available for the selected MCU?

Best regards

A. Willer

2 REPLIES 2

Not a chip I'm actively using. Datasheet should be good. Make sure to enable the GPIO C clocks to access registers.​

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

I can imagine AFRx got optimized out once there's only one AF for the PCx pins.

Make sure MODER for this pin is set to AF.

Even better, start with a simple blinky - set MODER for this pin to Out and wiggle the pin "manually" by writing to ODR/BSRR. You can do this in the debugger without writing any code.

JW