2021-10-22 09:02 AM
in software package STM32L0 1.12.1
in file stm32l0xx_hal_gpio.c
in function void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
The pin is deinited by setting it as input floating:
/* Configure IO Direction in Input Floting Mode */
GPIOx->MODER |= (GPIO_MODER_MODE0 << (position * 2U));
But on STM32L0x3 all the pins are configured as ANALOG after a reset.
See also the reference manual RM0367 (Section "9.4.1 GPIO port mode register (GPIOx_MODER)").
The code above should be replaced with
/* Configure IO Direction as Analog Mode */
GPIOx->MODER |= (GPIO_MODER_MODE3 << (position * 2U));
I'm assuming that all the devices in the L0 family have pins defaulting to ANALOG; otherwise, the code above should be tailored to the various subfamilies.
Solved! Go to Solution.
2021-10-23 02:07 AM
This one is not a bug. Floating mode is the analog mode. The zero in "MODE0" is a pin number, not an I/O mode. The GPIO_MODER_MODE0 is a bit field mask with a value 3. Look at the code:
P.S. Semantically using a bit field mask doesn't make sense. Instead they should use the reset value, which is just a simple number 3, or define something like GPIO_MODER_MODE_ANALOG or GPIO_MODER_MODE_RESET.
2021-10-23 02:07 AM
This one is not a bug. Floating mode is the analog mode. The zero in "MODE0" is a pin number, not an I/O mode. The GPIO_MODER_MODE0 is a bit field mask with a value 3. Look at the code:
P.S. Semantically using a bit field mask doesn't make sense. Instead they should use the reset value, which is just a simple number 3, or define something like GPIO_MODER_MODE_ANALOG or GPIO_MODER_MODE_RESET.
2021-10-25 12:05 AM
You're right, I mistook the meaning of MODE0.
Also the comment about "input floating" - which to me means "input mode without pull-up or pull-down", not "analog" - contributed to the confusion.
Indeed, other families' files (h7, f4, l4) have an appropriate comment, either "Input Floating" (0x0) or "Analog" (0x3)
Thanks
2021-10-25 06:47 AM
Hi @Community member & @Piranha ,
I tracked your proposals in Internal ticket number: 116446 (This is an internal tracking number and is not accessible or usable by customers).
Thanks for sharing your thoughts.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.