cancel
Showing results for 
Search instead for 
Did you mean: 

Pins with multiple alternate functions in STM32F103

danesh
Associate II
Posted on July 21, 2015 at 10:45

Hi all,

I am working with a STM32F103 MCU. In this MCU, some pins have multiple alternate functions such as PA8 which has the following alternate functions ''USART1_CK/TIM1_CH1/MCO''. If I simply define such pin e.g. PA8 as GPIO_Mode_AF_PP, which function would be activated? Would it be automatically selected by MCU based on the connection of the pin? In my case, I have a Secure Access Module (SAM) which is connected to my MCU and PA8 is connected to the clock input of SAM, so in my case it would be reasonable to use USART1_CK since other SAMs in my design are connected to UARTx_CKs. Would MCU detect the clock input of SAM and activate USART1_CK among other functions in PA8?

Thanks for your help,

Dan.

4 REPLIES 4
raptorhal2
Lead
Posted on July 21, 2015 at 15:30

Register bits set by software control which alternate function is selected.

Read the section on alternate functions in the reference manual.

Cheers, Hal

danesh
Associate II
Posted on July 22, 2015 at 14:54

I didn't find such information neither in datasheet or reference manual. In example no bit is also set to chose between alternate functions. My guess is that enabling clock for a group of functions will decide over what alternate function is used. For instance, if alternate functions in PA8 is going to be used, the peripheral clock for USART1 or TIM1 which is enabled, will decide which alternate function will be used. This how examples use alternate functions at least, but I am not sure.

danesh
Associate II
Posted on July 22, 2015 at 15:43

There are in fact two registers i.e. GPIOx->AFRL and GPIOx->AFRH which are used to multiplex between several alternate function in STM32F4xx series, bit there are not such registers in STM32 F103 which I am using now.

raptorhal2
Lead
Posted on July 22, 2015 at 16:50

You are mostly correct. The peripheral clock enables the peripheral, but I believe it is up to your program to make sure that only one alternate function is active on the pin.

Cheers, Hal