stm32 的spi 设置如下
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; ///SPI_CPOL_High sck 空闲时 为高电平
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;//在sck第一个跳沿对输入 输出数据采样
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;//需要考虑芯片的速度
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
发送程序 如下
while(1){
LowSpiLatch();
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
SPI2->DR = 0x88;//(u16)(SPI_OutExpland>>16) ; //输出到扩展IO,先发低16位
/* Wait for SPI2 Tx buffer empty */
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
SPI2->DR = 0x11; //输出到扩展IO,先发低16位
if(TypeMode==General_IO)
Hight_Latch_O;//the 595 need a positive-going signel
}
输出应该是DO1~DO2=0x11 ; DO1~DO2=0x88;
但是输出时DO1~DO2=0xC4 ; DO1~DO2=0x01;
即整个32bit 循环右移动了一位,是什么导致这样的呢???
|