Skip to main content
Visitor
September 16, 2026
Question

Random SPI communication timeout with STM32H7 when reading sensor data continuously

  • September 16, 2026
  • 3 replies
  • 16 views

I am working on an STM32H7-based project where I continuously poll sensor data over SPI in DMA mode. Everything works as expected for the first few hours, but occasionally the SPI bus freezes and triggers a timeout error (HAL_SPI_ERROR_TIMEOUT).

Resetting the SPI peripheral manually recovers the communication, but I want to identify the root cause instead of using a soft-reset workaround.

Has anyone encountered similar bus lockup issues with STM32H7 SPI DMA implementation? Any tips on proper flag clearing or clearing the FIFO buffer safely would be greatly appreciated!

3 replies

Andrew Neil
Super User
September 16, 2026

Have you:

  1. Checked your I2C lines with an oscilloscope to confirm that they are clean, have good edges, correct levels, etc?
  2. Used an analyser to capture comms; check timing; see what happens at the point the software errors?
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.
Visitor
September 16, 2026

Thanks for the suggestions

To clarify, I'm actually using SPI not I2C but I did hook up a logic analyzer to capture the lines during the failure. The CLK, MOSI and CS signals look clean with sharp edges and there are no obvious signal integrity issues or ringing on the scope.

Ryan Miles
Andrew Neil
Super User
September 16, 2026

To clarify, I'm actually using SPI not I2C 

Sorry - my typo!

 

 I did hook up a logic analyzer ... signals look clean with sharp edges

A logic analyser will always show clean traces with sharp edges - you need to check these things on the oscilloscope.

This is where a logic analyser can mislead if the actual signals are not clean with sharp edges.

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.