cancel
Showing results for 
Search instead for 
Did you mean: 

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

unicyclebloke
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
unicyclebloke
Associate III

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

View solution in original post

4 REPLIES 4
mƎALLEm
ST Employee

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.
unicyclebloke
Associate III

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

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.
unicyclebloke
Associate III

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.