cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 Alternate Function selection for a specific pin.

YAkse
Associate III

Hi, I am familiar with STM32F407 from my previous works. In that 40xx family, it was easy to understand, there are AFRL and AFRH registers by which user can select the desired AF for each and every pin independently.

However, now, I am working with STM32F103C8T6 MCU, and even I read the related docs several times, I really could not understand how to ensure to assign only the desired AF to a pin.

Please see the visualization here.

Let me take PB6 for example, I see that, both I2C1 and TIM4 Channel 1 is related with PB6, but I want to use it for I2C1. What should I do to ensure there won't be any conflicts?

Do I have to remap TIM4 manually to anywhere else?

What will happen if I don't do that?

If TIM4 and USART1 is not activated(their clocks), then can I say it is safe to rely on the fact that the only active AF on PB6 is I2C1 SCL ?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

> how to ensure to assign only the desired AF to a pin

You can't. The AFs are assigned in a fixed manner. Some of the AFs can be "remapped" using AFIO; if they after remap "land" on the same pin, both AFs are active on that pin at the same time.

> Please see the visualization here.

Copy/paste picture does not work properly in salesforce, which is here used instead of proper forum software. You'll need to upload the picture file (see "landscape" icon below the editor window).

JW

View solution in original post

4 REPLIES 4

> how to ensure to assign only the desired AF to a pin

You can't. The AFs are assigned in a fixed manner. Some of the AFs can be "remapped" using AFIO; if they after remap "land" on the same pin, both AFs are active on that pin at the same time.

> Please see the visualization here.

Copy/paste picture does not work properly in salesforce, which is here used instead of proper forum software. You'll need to upload the picture file (see "landscape" icon below the editor window).

JW

if all peripherals other than the source of the desired AF are disabled on a pin, can I rely on it safely?

I edited the question, there was a mistake at first, fixed now

> if all peripherals other than the source of the desired AF are disabled on a pin, can I rely on it safely?

Yes.

Read also the errata, to be sure.

JW