cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L052K8U inputs randomly not working after a while

Yves Bmnt
Associate III

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

4 REPLIES 4
Andrew Neil
Super User

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?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Ozone
Principal III

> 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.

Danish1
Lead III

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

waclawek.jan
Super User

Which 2 pins?

JW