armstm32microcontrollerstm32cubemx

in STM32F10, for instance, when i enable the Usart1 why doesnt the CUBEMX call HAL_GPIO_Init to set the alternate function of the corresponding pins?


I just try to understand how the .ioc(cubemx) file respond to the configuration i set into my MCU and when i enable a peripheral lets say usart or whatsoever, it has to generate the code associated with setting the corresponding pins allocated to that specific peripheral(usart) but when i check the code i cant find the section where it does (i tested for a gpio and set it as output and the cubemx just generated the code (HAL_GPIO_Init) )!! how does it work? enter image description here enter image description here

Where is the code associated with the Pin configuration?


Solution

  • Have a look in Core/Src, you should see a file called stm32f1xx_hal_msp.c or similar.

    It will have a function in it called HAL_UART_MspInit(). This configures the GPIO pins used by your UART.