Skip to main content
NVoid.1
Associate
March 19, 2021
Solved

STM32CubeIDE code generate "LL_GPIO_SetOutputPin" in inappropriate code line

  • March 19, 2021
  • 2 replies
  • 2150 views

chip: F103VET6

IDE version: STM32CubeIDE v1.6.0 Build: 9614_20210223_1703 (UTC)

Firmware Package : STM32Cube FW_F1 V1.8.3​

Lib: low layer driver​

in GPIO Configuration:

​ �?GPIO output level �? generate code BEFORE GPIO_init, that makes LL_GPIO_SetOutputPin invalid.

---------------------------------------------------------------------------------------------------

void MX_GPIO_Init(void)

{

 LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* GPIO Ports Clock Enable */

 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);

 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);

 /**/

 LL_GPIO_SetOutputPin(GPIOB, LEDG_Pin|LEDB_Pin|LEDR_Pin);

 /**/

 GPIO_InitStruct.Pin = LEDG_Pin|LEDB_Pin|LEDR_Pin;

 GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;

 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;

 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;

 LL_GPIO_Init(GPIOB, &GPIO_InitStruct);

}​

This topic has been closed for replies.
Best answer by Piranha

No, that is not inappropriate and not a bug. The peripheral clocks are already enabled and LL_GPIO_SetOutputPin() is not related to LL_GPIO_Init(). It is done deliberately for the output value to be at the desired level immediately when LL_GPIO_Init() switches the pin to an output mode.

LL is not a high-level library and is basically renamed register level programming. The only thing it adds is another layer of (small) bloat and potential bugs, and doubles the amount of work, because one has to translate everything from LL to registers and back.

2 replies

Piranha
PiranhaBest answer
Principal III
March 19, 2021

No, that is not inappropriate and not a bug. The peripheral clocks are already enabled and LL_GPIO_SetOutputPin() is not related to LL_GPIO_Init(). It is done deliberately for the output value to be at the desired level immediately when LL_GPIO_Init() switches the pin to an output mode.

LL is not a high-level library and is basically renamed register level programming. The only thing it adds is another layer of (small) bloat and potential bugs, and doubles the amount of work, because one has to translate everything from LL to registers and back.

NVoid.1
NVoid.1Author
Associate
March 20, 2021

Thanks a lot for your explanation.