STM32F407之SPI

一,基础知识

1,SPI允许数据一位一位的传送,甚至允许暂停,因为SCK时钟线由主控设备控制,当没有时钟跳变时,从设备不采集或传送数据。

2,SPI是一个数据交换协议,因为SPI的数据输入和输出线独立,所以允许同时完成数据的输入和输出。

3,SPI的SCK信号线只由主设备控制,从设备不能控制信号线。

4,SPI,在点对点的通信中,不需要进行寻址操作,且为全双工通信。

5,

二,实践

1,在主设备这边配置SPI接口时钟的时候一定要弄清楚从设备的时钟要求,因为主设备这边的时钟极性和相位都是以从设备为基准的。因此在时钟极性的配置上一定要搞清楚从设备是在时钟的上升沿还是下降沿接收数据,是在时钟的下降沿还是上升沿输出数据。但要注意的是,由于主设备的SDO连接从设备的SDI,从设备的SDO连接主设备的SDI,从设备SDI接收的数据是主设备的SDO发送过来的,主设备SDI接收的数据是从设备SDO发送过来的,所以主设备这边SPI时钟极性的配置(即SDO的配置)跟从设备的SDI接收数据的极性是相反的,跟从设备SDO发送数据的极性是相同的。

2,(W25Q128数据手册)The W25Q128BV supports standard SPI, Dual SPI and Quad SPI operation. Standard SPI instructions use the unidirectional DI (input) pin to serially write instructions, addresses or data to the device on the rising edge of the Serial Clock (CLK) input pin. Standard SPI also uses the unidirectional DO (output) to read data or status from the device on the falling edge of CLK.

3,不同的SPI从设备出厂时就被配置为某种工作模式,这是不能改变的。我们需要是SPI主从设备工作在同一模式下。

4,SPI通信没有专门的通信周期、通信起始信号、通信结束信号。当没有数据交流的时候,时钟线要么保持高电平,要么保持低电平。

5,(W25Q128数据手册)SPI bus operation Mode 0 (0, 0) and 3 (1, 1) are supported. The primary difference between Mode 0 and Mode 3 concerns the normal state of the CLK signal when the SPI bus master is in standby and data is not being transferred to the Serial Flash. For Mode 0, the CLK signal is normally low on the falling and rising edges of /CS. For Mode 3, the CLK signal is normally high on the falling and rising edges of /CS.

6,

猜你喜欢

转载自www.cnblogs.com/stephen-mcu-tech/p/9261129.html