How to use ALT pins on STM32?
On STM32 , “ALT pins” usually means alternate functions (AF): using a GPIO pin for USART/SPI/I²C/TIM PWM/ADC, etc. You pick the pin’s AF mapping in CubeMX (or write the GPIO registers yourself). Here’s the practical way. The CubeMX way (recommended) Open STM32CubeMX (or CubeIDE → .ioc ). Go to Pinout & Configuration . Enable the peripheral you want (e.g., USART1 , SPI2 , TIM3 PWM ). CubeMX will assign default pins. To use “alt pins”: Click the pin on the package view (e.g., PA9) Choose the function you want (e.g., USART1_TX ) Or open the peripheral settings → GPIO Settings and select alternate pins there. In GPIO Configuration ensure: Mode = Alternate Function Push-Pull (most digital AF signals) Pull-up/down as needed Speed set appropriately (higher for fast edges like SPI) Generate code. CubeMX will create: MX_GPIO_Init() HAL_UART_MspInit() / HAL_SPI_MspInit() etc. that set the AF. Typical HAL GPIO init snippet ...