cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 : can I define the same alternate function for 2 different peripherals?

jean
Senior

Hello!

I'm working on a STM32H743

I use a USB DEVICE driver (pins PB14 and PB15) : only AF12 is possible

I also use a SD card driver (PC8 ... PC12) : only AF12 is possible

(Alternate function mapping is described in the datasheet https://www.mouser.fr/datasheet/2/389/stm32h743vi-1760857.pdf page 89)

But I did not find this information: is it possible to use the same alternate functions for 2 different peripherals, on 2 different ports?

Thanks a lot for your help!

Jean

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hi @jean​ 

First, STM32CubeMX tool should help for pins assignment and suitable alternate functions activation.

Second, having each I/O function include a multiplexer to select which pin it should accept input from, and another for output data.

Such a design makes it possible to have one pin feed multiple I/O functions, while simultaneously eliminating any ambiguities posed by conflicting configurations.

Please refer to reference manual STM32H742, STM32H743/753 and STM32H750 Value line advanced Arm®-based 32-bit MCUs - Reference manual section 11.4.9 and 11.4.10 for configuring the registers of GPIOx_AFRL & GPIOx_AFRH

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6

AF - here 12 - is just a number written to register which controls the multiplexer on given pin.

The individual pins are entirely independent of each other.

So,

> is it possible to use the same alternate functions for 2 different peripherals, on 2 different ports?

yes.

JW

S.Ma
Principal

Multiple gpios can have same AF. The "only" doesn't apply at first glance.

What you imagine will apply for EXTI and Gpio pin vs port name.

Now a fun extended question for JW: what happens if the same peripheral signal is activated on two or more gpios? .... that might not be in the refman.... ?

>>what happens if the same peripheral signal is activated on two or more gpios

Here be Dragons..

For peripheral outputs, might work, for inputs likely going to fight or interfere

Into the whole "undefined operation" realm, where the HW doesn't protect you from yourself

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

>> what happens if the same peripheral signal is activated on two or more gpios

> Here be Dragons..

http://www.efton.sk/STM32/gotcha/g92.html

I understand why ST won't document this ever - the implementations may be flaky and any stated rule would probably quickly find exceptions (there already are known ones, e.g. the built-in USB PHY DP/DM pins in fact ignore the AF setting (and even MODER setting) in GPIO in 'F407, could be looked up here on forum). And, contrary to what I wrote there, I seem to recall that there *is* a rule to use exactly one AF per peripheral pad, in the GPIO chapter, at least in some RM - e.g. RM0390 for 'F446:.

Note: The application is allowed to select one of the possible peripheral functions for each I/O at a time.

I might be revising that article. [EDIT] Done. [/EDIT]

There are more such undefined (e.g. using undefined AF, look at my post starting Through a copy/paste...) or just badly documented things in GPIO, but this all unecessarily confuses @jean - he is concerned about the value 12 being used in distinct pins' setup for distinct peripherals.

JW

FBL
ST Employee

Hi @jean​ 

First, STM32CubeMX tool should help for pins assignment and suitable alternate functions activation.

Second, having each I/O function include a multiplexer to select which pin it should accept input from, and another for output data.

Such a design makes it possible to have one pin feed multiple I/O functions, while simultaneously eliminating any ambiguities posed by conflicting configurations.

Please refer to reference manual STM32H742, STM32H743/753 and STM32H750 Value line advanced Arm®-based 32-bit MCUs - Reference manual section 11.4.9 and 11.4.10 for configuring the registers of GPIOx_AFRL & GPIOx_AFRH

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

jean
Senior

Hi everybody,

Thanks a lot for all your explanation and ressources, that's very interesting.

I confirm that having same alternate functions for different peripherals is working in my case.

Have a great week!