首页 > 编程知识 正文

spi协议详解,SPI传输协议

时间:2023-05-06 07:41:00 阅读:187830 作者:4757

SPI通信协议技术说明文档

简介:
SPI通信是串口外设接口的缩写。Motorola公司推出的一种同步串行接口技术,是一种高速的、全双工、同步的通信总线。四根线分别为MOSI、MISO、CLK、CS(片选)。

网络拓扑:

数据传输

Data transfer starts with the falling edge of the CS signal. Execution of new input data is enabled on the rising edge of the CS signal. Data must appear at DI synchronized to CLK and is accepted on the falling edge of the CLK signal.LSB (bit 0, SRR) has to be transferred first.The output data at DO is enabled on the falling edge of CS. Output data will change their state with the rising edge of CLK and stay stable until the next rising edge of CLK appears. When CS is high, pin DO is in a tri-state condition. LSB (bit 0,TP) is transferred first.




总结 可靠性差,无应答机制,无法确认数据是否正确接收到数据。 源码 void DriveSpi(void){uint16_t i,j;spiData[0] = 0;spiData[13] =1; // OLDspiData[14]=1; // SCTspiData[15] = 1; // SE // for(j=0;j<12;j++); //10us least /*if(SO[13]==1||SO[14]==0||SO[15]==1){if(SO[13]==1)spiData[13]=0;elsespiData[13]=1;if(SO[14]==1)spiData[15]=1;elsespiData[15]=0;} */ CSB_L;for(i=0;i<16;i++) {SCK_H;if(spiData[i]){MOSI_H;}else{ MOSI_L;}if(MISO) {SO[i]=1;}else {SO[i]=0;}for(j=0;j<3;j++); // 6SCK_L;for(j=0;j<3;j++); // 6}for(j=0;j<2;j++);CSB_H;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。