最近在调试硬件SPI,之前使用软件模拟方式,为了提高速度,选择该方式进行替换。
花了一些时间了解寄存器跟库函数直接调用,结果要么读取不出数据(陷入等待TXE,RXNE死循环)或读取数据为0xffff,0x0101(nSS拉低之后没有跳变,或者Send/Write分开写,没有形成环形FIFO Shift,根据全双工协议,读写应该同时进行)。后来才在网上查找资料,并认真阅读STM32的RM,整理如下:
1、整体的框架如图
2、nSS详解
In slave mode, the NSS works as a standard “chip select” input and lets the slave communicate with the master. In master mode, NSS can be used either as output or input.As an input it can prevent multimaster bus collision, and as an output it can drive a slave
select signal of a single slave.