# SPI: DMA传输不完整，通道1上预期256字节但仅接收128字节

- **ID:** `embedded/spi-dma-transfer-incomplete`
- **领域:** embedded
- **类别:** data_error
- **错误码:** `SPI_DMA_INCOMPLETE`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

SPI DMA传输因超时、FIFO溢出或从设备在传输中途取消片选而过早终止。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32Cube_FW_F7 v1.17.0 | active | — | — |
| STM32Cube_FW_G4 v1.6.0 | active | — | — |
| DMA HAL Driver v2.3.0 | active | — | — |

## 解决方案

1. ```
   Add a DMA transfer complete callback (HAL_SPI_TxRxCpltCallback) to verify the received byte count and re-initiate the transfer if incomplete.
   ```
2. ```
   Enable SPI CRC checking to detect data corruption and retry the transfer on CRC mismatch.
   ```

## 无效尝试

- **Increase the SPI clock speed to transfer data faster** — Higher clock speed can exacerbate timing issues and cause more FIFO overflows, worsening the problem. (80% 失败率)
- **Disable DMA and use polling SPI transfer instead** — Polling transfers can block the CPU for long periods, causing real-time task failures and still not resolving the root cause of incomplete transfers. (75% 失败率)
