cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE code generate "LL_GPIO_SetOutputPin" in inappropriate code line

NVoid.1
Associate

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);

}​

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

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.

View solution in original post

2 REPLIES 2
Piranha
Chief II

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.

Thanks a lot for your explanation.