2025-06-28 2:27 AM
Hello everyone,
I'm currently working with an STM32F746 microcontroller as an SPI slave using DMA for data reception.
The SPI master sends fixed-size packets of 512 bytes, and everything works fine most of the time. However, occasionally, a few bytes (e.g., 4 bytes) seem to get lost during transmission or reception. After that, the SPI slave continues receiving data, but everything becomes misaligned by that number of lost bytes. This causes the following packets to be parsed incorrectly and fail CRC checks.
I need a way to recover synchronization after such a misalignment — that is, to detect when a packet is no longer aligned to the expected 512-byte structure, and then find the correct boundary again so I can resume proper packet parsing.
Has anyone encountered a similar issue? I’d appreciate it if you could share any ideas or solutions on how to resynchronize the SPI DMA stream after a data loss event.
Thanks in advance and have a great day!