2026-01-27 5:46 AM - edited 2026-01-27 7:05 AM
Hi all,
In my project I use several IOs, I2C, SPI, UART, ADC, DAC and most of them work as expected.
However, I have 2 inputs from push buttons (pushing the button would set them to 0 volt), set with pull-ups (not set as EXTI) that sometimes stop working after a while: When I check the voltage I see the level is changing, but when reading these IOs using HAL_GPIO_ReadPin() their state doesn't change anymore until I reset the PCB.
The rest of the software still works fine when it happens.
Never seen this before on ST, and this project was actually migrated from STM32L031 which never showed the issue. I'm having a hard time reproducing the bug, it seems very random so far.
If I called the GPIO Init on a regular basis, would it prevent this issue?
Kind regards
P.S: I use GNU tools for STM32 v13.3.rel1
2026-01-27 6:12 AM
Please give more details about your setup:
How to write your question to maximize your chances to find a solution
@Yves Bmnt wrote:when reading these IOs using HAL_GPIO_ReadPin() their state doesn't change anymore Kind regards
What if you look at the port data register directly?
Have you checked the other port registers to check the configuration is still correct?
2026-01-27 6:38 AM
> However, I have 2 inputs set with pull-ups (not set as EXTI) that sometimes stop working after a while: When I check the voltage I see the level is changing, but when reading these IOs using HAL_GPIO_ReadPin() their state doesn't change anymore until I reset the PCB.
I would run the board in a debugger until the problem happens, and then compare the peripheral register settings for any changes.
"Random" occurences are often related to race conditions and / or stack overflows.
2026-01-27 6:55 AM
When the pins aren't behaving, do you know if they are reading 1 or 0?
A "gotcha" of GPIO pins is that if you set them to be Analog, any attempt to read the digital value will return 0. You need to return them to digital input to be able to read the digital value.
Maybe with L052 you're setting a pin to Analog on the wrong port.
(This is because the stm32 might otherwise consume unnecessary power when the voltage is somewhere between Vdd and Vss).
2026-01-27 7:05 AM
Which 2 pins?
JW