我想用SPI实现24位数据的发送,即时钟信号有连续24位波形。现在已经能够发送16位数据,但是始终不能连续24位数据的发送。附上我SPI模块相关程序。望斑竹能抽空看下问题所在,万分感谢! //SPI初始化 SPI0CR1=0x16; //SPI disable;SPI transmit interrupt disable;master mode;active high selected;CPOL=0;CPHA=1;高位在前发送 SPI0CR2=0x10; //ss is slave select output;miso: master in;mosi:master out SPI0BR=0x32; //时钟频率500khz; 500*40/16 void SPI_Write(UInt8 adder,UInt8 data) { PTS_PTS7=0; //拉低cs片选信号 if((SPI0SR&0x20)==0x20) { SPI0DR=MCP2510INSTR_WRITE; SPI0CR1=0x56; //enable the SPI } //PTS_PTS7=1; //发送第二个8位数据 if((SPI0SR&0x20)==0x20) { SPI0DR=adder; SPI0CR1=0x56; } // PTS_PTS7=1; if((SPI0SR&0x20)==0x20) { SPI0DR=data; SPI0CR1=0x56; } PTS_PTS7=1; //在SPI发送24位数据后拉高cs片选信号 }
|