2026-02-13 4:27 PM
Hi everyone,
I’m trying to design my first PCB using STM32F103 and I’m still a beginner.
I see that the PAx pins (PA0–PA15) have multiple alternate functions like GPIO, ADC, USART, SPI, etc.
I’m a bit confused about how to properly choose which PA pins to use for my peripherals.
If I use PA9/PA10 for USART, can I still use them as normal GPIO later?
What is functionality of PAx pins ?
I'm using STM32F103C8T6
stm32f103c8 datasheet
stm32f103c8t6
I'd really appreciate some guidance before I finalize my board layout.
Thanks!
Best Regards !
Solved! Go to Solution.
2026-02-14 3:48 AM - edited 2026-02-14 3:52 AM
Hello @braveyav and welcome to the ST community,
As you stated, each GPIO pin contains many alternate functions. To enable that function, you need to configure it by software. You can either modify that function at run time in your application but you need to ensure there will be no conflict externally by hardware.
What is functionality of PAx pins ?
-> look at the datasheet for each pin. For example: PA2 has three functions: UART2_Tx or ADC input or TIM2_ CH3
If you enable USART2 for example by software and select PA2 for Tx, PA2 will be reserved for this function. But as I stated before you can change that function in your application bu selecting TIM2 at runtime but you need to do that in a correct way.
Use CubeMx tool to configure the peripherals with their corresponding IOs. You can donwnload the tool from this link.
So you configure the peripherals with CubeMx and you generate the code with that configuration. Than you can use CubeDE tool (downloadable fom this link) and add the user code and compile/debug.
Read also this tutorial: STM32CubeIDE 2.0.0 workflow tutorial
Hope I've answred your question.
2026-02-14 3:48 AM - edited 2026-02-14 3:52 AM
Hello @braveyav and welcome to the ST community,
As you stated, each GPIO pin contains many alternate functions. To enable that function, you need to configure it by software. You can either modify that function at run time in your application but you need to ensure there will be no conflict externally by hardware.
What is functionality of PAx pins ?
-> look at the datasheet for each pin. For example: PA2 has three functions: UART2_Tx or ADC input or TIM2_ CH3
If you enable USART2 for example by software and select PA2 for Tx, PA2 will be reserved for this function. But as I stated before you can change that function in your application bu selecting TIM2 at runtime but you need to do that in a correct way.
Use CubeMx tool to configure the peripherals with their corresponding IOs. You can donwnload the tool from this link.
So you configure the peripherals with CubeMx and you generate the code with that configuration. Than you can use CubeDE tool (downloadable fom this link) and add the user code and compile/debug.
Read also this tutorial: STM32CubeIDE 2.0.0 workflow tutorial
Hope I've answred your question.
2026-02-15 2:05 PM
Thank you so much @mƎALLEm. So can we say that PAx pins are aliases for pins with multiple functions?
Best Regards !
2026-02-15 11:04 PM - edited 2026-02-16 7:15 AM
A pin could be used for many functions according to the datasheet. The function assignment configuration is done by software in the user application.
2026-02-16 1:49 AM
@braveyav wrote:So can we say that PAx pins are aliases for pins with multiple functions?
Probably a more useful description would say that the various different functions are multiplexed onto a pin; eg, for PA2 (from the datasheet extract posted by @mƎALLEm:(
Note that this is not unique to STM32 or ST - (pretty much?) all microcontrollers have more internal functions than physical pins, so they all have some way to "multiplex" multiple functions onto a single physical pin.
Precise details vary, but the principle is the same.
#AlternateFunctions
2026-02-16 7:12 AM - edited 2026-02-16 7:22 AM
"If I use PA9/PA10 for USART, can I still use them as normal GPIO later?"
Yes you can, your software can enable the pins as USART, then later reconfigure them.
But most designs allocate microcontroller pins to various functions permanently, pins switching function from USART to GPIO would be unusual; does the entity communicating via USART get physically disconnected in your system?
Such overloading complexity would typically only be considered if you have run out of microcontroller pins.
As @mƎALLEm mentioned, you can use CubeMx to allocate microcontroller pins to various functions in your system, ideally you will have enough pins for all your system's needs. Or carefully study the datasheet and allocate pins as needed.
2026-02-16 7:59 AM - edited 2026-02-16 8:23 AM
@braveyav wrote:I see that the PAx pins (PA0–PA15) have multiple alternate functions !
Not just the PAx pins - also some PBx on this particular chip.
In general, any PXy pin could have multiple alternate functions.
2026-02-16 8:23 AM
Going one step further, the switch as drawn by @Andrew Neil above can in fact be broken to two switches: one selects between GPIO (more specifically, GPIO output) and the input to the other switch, this is called Alternate Function. The second switch then selects between TIM, USART, ADC.
However, in STM32F1xx, the method *how* that function is switched, is different from all other STM32. It was the first STM32 family and ST did not figure out the right way to do yet. So, while in all other STM32 thre's a dedicated register to steer that second switch, in the 'F1 family, it's steered by whichever peripheral's clock is enabled in RCC. This is then further complicated by the need to select groups of pins associated to given peripheral, in the AFIO module.
What I'm trying to get at is, that the STM32F103 is not the best candidate for the first STM32 to be used by a novice.
JW