cancel
Showing results for 
Search instead for 
Did you mean: 

How to remap an alternate function from one GPIO to another using STM32CubeMX

ST AME Support NF
ST Employee

 

How do I remap an alternate function from one GPIO to another using STM32CubeMX?

 

Most of the alternate functions on STM32 Microcontrollers can be remapped to other GPIOs. Refer to the product's datasheet for the alternate function mapping options available.

1. Remap an alternate function from one GPIO to another


Let's see how we can remap an alternate function from one GPIO to another using STM32CubeMX.
  • I have selected an STM32G071RBTx
  • I would like to remap the SPI1_SCK alternate function.
  • I am enabling SPI1 from STM32CubeMX and the tool will select default GPIOs as seen below:

1869.png
2. Remap SPI1_SCK

Let's say I would like to remap the SPI1_SCK signal to another GPIO offering the same Alternate Function.

To do this, place the mouse pointer on the pin PA1, press and hold the Control key (CTRL) and then left click the mouse. This will highlight the remapping options available, as indicated by the black background fill for the GPIO pins PA5, PB3 and PD8 (see figure below):

1870.png

3. Practical example: remap SPI1_SCK to PD8 

Let's imagine we want to remap SPI1_SCK to PD8, with CTRL and left clock still pressed you want to drag and drop from PA1 to PD8 and that will select SPI1_SCK to be configured for PD8 as show below:
1871.png
Et voila!

4. Links

STM32CubeMX - STM32Cube initialization code generator - STMicroelectronics
Comments
ST AME Support NF
ST Employee

Thank you

John KNAB
ST Employee

Thanks for this publishing this article.

Version history
Last update:
‎2021-09-13 12:45 AM
Updated by: