Skip to main content
Associate III
July 7, 2025
Solved

STM32U575: GPIOx->BSRR assignment causes reset - but only when debugging

  • July 7, 2025
  • 3 replies
  • 390 views

My project is using a GPIO to enable/disable a buzzer on a software timer. This boils down to a call to  HAL_GPIO_WritePin(), which does GPIOx->BSRR = pinmask (0x80 in this case) to enable the buzzer. This works as expected most of the time. There are multiple calls to this function on the same pin on the same port which work correctly. And then... Boom! I have a very repeatable situation in which the register assignment immediately causes the device MCU to reset. I have implementations for hard faults, bus faults, and so on, but the code doesn't seem to go there (breakpoint instructions in place).

It turns out that this fault does not happen unless the debugger is connected. The reset does not disconnect from the debugger. I'm not stepping the code to make this happen.

What are possible causes for this error? I previously had an unrelated fault which only happened while stepping the code (a race condition tripped by a missed interrupt). While it was not an issue for the application, it was good to fix it anyway. My guess is that this issue might be somewhat like that.   

Thanks

Best answer by unicyclebloke

I'm such an ***. The PSU current max was a shade too low. 

3 replies

mƎALLEm
Technical Moderator
July 7, 2025

Hello,

If you disconnect the buzzer from the GPIO, do you get the same behavior?

If you are not able to disconnect the buzzer and if you don't set the GPIO buzzer, do you get the same behavior?

"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."
unicycleblokeAuthorBest answer
Associate III
July 7, 2025

I'm such an ***. The PSU current max was a shade too low. 

mƎALLEm
Technical Moderator
July 7, 2025

Did you change a suitable power supply and it worked?

"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."
Associate III
July 7, 2025

Yeah. In fact I just turned the dial a bit. It seems there is a short spike we weren't expecting. Oh well. Thanks for playing.