embedded
hardware_error
ai_generated
true
SPI:GPIO线路上检测到片选信号毛刺,导致从设备被误选中
SPI: chip select glitch detected on GPIO line, causing false slave selection
ID: embedded/spi-cs-glitch-on-gpio
90%修复率
86%置信度
1证据数
2024-06-01首次发现
根因分析
片选GPIO线由软件驱动或驱动强度不足,在GPIO切换时产生短暂低电平脉冲(毛刺),导致SPI从设备被误选中或取消选中。
English
The chip select (CS) GPIO line is driven by software or has insufficient drive strength, causing a brief low pulse (glitch) during GPIO toggling, which falsely selects or deselects the SPI slave.
官方文档
https://www.st.com/resource/en/application_note/an4031-stm32-spi-protocol.pdf解决方案
-
Enable the SPI peripheral's hardware NSS (automatic chip select) if available. Example on STM32: hspi.Init.NSS = SPI_NSS_HARD_OUTPUT; then configure the CS pin as SPI_NSS alternate function.
-
Add a 10kΩ pull-up resistor on the CS line to hold it high during GPIO transitions, and set the GPIO output to open-drain with a weak drive.
无效尝试
常见但无效的做法:
-
70% 失败
Adding a delay before toggling CS does not eliminate the glitch; the glitch occurs during the transition itself.
-
60% 失败
Changing the GPIO output speed to high increases the glitch amplitude due to faster slew rate, making the problem worse.