2021-03-18 11:09 PM
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);
}
Solved! Go to Solution.
2021-03-19 12:38 AM
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.
2021-03-19 12:38 AM
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.
2021-03-19 07:28 PM
Thanks a lot for your explanation.