Skip to main content
Jalon Wong
Associate
April 13, 2018
Question

Variable not initialized in STM32 LL MX_GPIO_Init()

  • April 13, 2018
  • 2 replies
  • 750 views
Posted on April 13, 2018 at 09:24

STM32CubeMX v4.0

STM32CubeF1 Firmware Package v1.6.1

The following is the code generated by STM32CubeMX.

void MX_GPIO_Init(void)
{
 LL_GPIO_InitTypeDef GPIO_InitStruct; 
 // ... 
 GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; 
 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; 
 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 
 LL_GPIO_Init(GPIOC, &GPIO_InitStruct); 
 //... 
}
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct) 
{
 //... 
 assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull)); 
 //... 
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

The memberPullis notinitialized that leads to the program may be blocked atassert_param().

Hope to improve.Thanks !

#ll-gpio
This topic has been closed for replies.

2 replies

ST Technical Moderator
April 16, 2018
Posted on April 16, 2018 at 11:59

Hello,

Your reported issue is raised internally to CubeMx team for check.

Best Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jim Frederick_2
Associate II
April 16, 2018
Posted on April 16, 2018 at 13:36

I've seen the same problem for years.

One work-around is to modify the code to initialize the struct to zero e.g.,

LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

When re-generating code, merge the new file (probably main.c in this case) with a backup of the old file using a code-merging utility and keep your changes.