Pins with multiple alternate functions in STM32F103
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-21 1:45 AM
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-21 6:30 AM
Register bits set by software control which alternate function is selected.
Read the section on alternate functions in the reference manual. Cheers, Hal- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-22 5:54 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-22 6:43 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-22 7:50 AM
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