Skip to main content
FKaes.1
Associate III
May 12, 2025 1:25 PM UTC
Solved

STM32U5: Spi and Debug

Hello, this is a general question for my understanding.

when I single stepped* through my SPI code, I encountered some unexpected behavior. But when I run over the code, it worked as expected.

*During this time, I had the peripheral SPI view opened.

So my question is, when the debugger updates the view, e.g. by showing me the content of the SPI_RXDR register in the peripheral view, will this already have an effect on the SPI HW, like when I read the SPI_RXDR with SW ?

Or can the debugger read the registers somehow different ?

(A read to SPI_RXDR will have effect to RXFIFO and Rx-Flags)

FKaes1_0-1747056024248.png

 

 

 

 

 

This topic has been closed for replies.
TDK
TDKBest answer
May 12, 2025 1:45 PM UTC

> So my question is, when the debugger updates the view, e.g. by showing me the content of the SPI_RXDR register in the peripheral view, will this already have an effect on the SPI HW, like when I read the SPI_RXDR with SW ?

Yes, this reads RXDR which clears the RX buffer.

> Or can the debugger read the registers somehow different ?

No, the debugger uses the same reading mechanism as the cpu and has the same effects on the flags.

"If you feel a post has answered your question, please click ""Accept as Solution""."

3 replies

TDK
TDKBest answer
May 12, 2025 1:45 PM UTC

> So my question is, when the debugger updates the view, e.g. by showing me the content of the SPI_RXDR register in the peripheral view, will this already have an effect on the SPI HW, like when I read the SPI_RXDR with SW ?

Yes, this reads RXDR which clears the RX buffer.

> Or can the debugger read the registers somehow different ?

No, the debugger uses the same reading mechanism as the cpu and has the same effects on the flags.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Andrew Neil
Super User
May 12, 2025 1:54 PM UTC

@TDK wrote:

the debugger uses the same reading mechanism as the cpu and has the same effects on the flags.


@FKaes.1 this applies in general to any & all registers.

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.
FKaes.1
FKaes.1Author
Associate III
May 13, 2025 6:03 AM UTC

Hi, just to confirm it, I checked with SPI view open and closed. And the behavior was like explained. With open SPI view, I wasn't able to step over my code (because the RX flags were changed, when the debugger read and display the SPI register). But with closed SPI view, I was able to step over the SPI RX code.