Search code examples
stm32keilcortex-m

Keil debugger changes the hardware state of STM32H7 regarding FIFOs


I encountered the following issue while using Keil MDK 5 for STM32H743.

I had a communication problem with my SPI code and after a while I found out that it was due to the Periodic Windows Update.

When it is activated, it seems that the debugger is reading regularly the SPI data register, which reads the FIFO (so changes the state of the FIFO). Consequently when the software reads the FIFO, some bytes have been "lost" (or consumed by the debugger).

Is it an expected behaviour ? Do you know if it is due to Keil or to the STM32 ?

I don't fully understand how an access from the debugger to a register is working: I guess there is a read command sent over SWD but then, internally does the access to memory go through AHB / APB like for code executing on the CPU ?


Solution

  • Any registers that modify behaviour by being read (such as clearing status bits) can be problematic when debugging and the registers are shown in the debug window.

    The best bet is to only look at the registers when you stop (close the DR window for the peripheral), and always be aware that you may clear status bits etc.

    It is the way the processor works and nothing to do with the debugger.

    It is a very common debug issue with serial comms etc.