on
2021-09-13
12:45 AM
- edited on
2025-08-01
4:23 AM
by
Laurids_PETERSE
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.
Let's see how we can remap an alternate function from one GPIO to another using STM32CubeMX.
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):
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:
Et voila!
STM32CubeMX - STM32Cube initialization code generator - STMicroelectronics
Thank you
Thanks for this publishing this article.