cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX 6.1.1 No initial code inside MX_GPIO_Init using STM32H745-NUCLEO and Stm32CubeIDE

cchen.12
Associate III

static void MX_GPIO_Init(void)

{

 /* GPIO Ports Clock Enable */

 __HAL_RCC_GPIOC_CLK_ENABLE();

 __HAL_RCC_GPIOH_CLK_ENABLE();

 __HAL_RCC_GPIOA_CLK_ENABLE();

 __HAL_RCC_GPIOB_CLK_ENABLE();

 __HAL_RCC_GPIOD_CLK_ENABLE();

 __HAL_RCC_GPIOG_CLK_ENABLE();

}

Inside MX_GPIO_Init ,only the clock enable code.I must do initialization myself.

1 ACCEPTED SOLUTION

Accepted Solutions
Khouloud ZEMMELI
ST Employee

Hello @cchen.1​ 

Thanks for your question,

In fact, for the LL project, the GPIO Configuration will be generated under the MX_xx_Init() function (xx: IP used) when Pins are linked to an IP following its activation, otherwise, the Configuration code will be automatically generated under the MX_GPIO_Init(void) function.

Now, for HAL project, which is normally your case, the MX_GPIO_Init(void) function contains, as you said, only the clock enable for the GPIOx used during the activation of some IPs, for the rest of code, which present the GPIO Configuration, is generated in the void HAL_ADC_MspInit function under stm32xx_hal_msp.c file.

NB: For pins which are assigned on pinout view (as the case of GPIO_input..) and when the MCU used is a dual core, you need to reserve one cortex for that pin (see image below) to be then generated.

0693W000007ESAUQA4.png 

Hope my answer helped you, when your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thanks, Khouloud

View solution in original post

1 REPLY 1
Khouloud ZEMMELI
ST Employee

Hello @cchen.1​ 

Thanks for your question,

In fact, for the LL project, the GPIO Configuration will be generated under the MX_xx_Init() function (xx: IP used) when Pins are linked to an IP following its activation, otherwise, the Configuration code will be automatically generated under the MX_GPIO_Init(void) function.

Now, for HAL project, which is normally your case, the MX_GPIO_Init(void) function contains, as you said, only the clock enable for the GPIOx used during the activation of some IPs, for the rest of code, which present the GPIO Configuration, is generated in the void HAL_ADC_MspInit function under stm32xx_hal_msp.c file.

NB: For pins which are assigned on pinout view (as the case of GPIO_input..) and when the MCU used is a dual core, you need to reserve one cortex for that pin (see image below) to be then generated.

0693W000007ESAUQA4.png 

Hope my answer helped you, when your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thanks, Khouloud