我的SPI能正确发送数据,但是接收数据有问题,能接收到数据,但是都是错误的数据,请高手指点? void spi_init(void) { SPI_InitTypeDef SPI_InitStructure; /* SPI2 configuration ------------------------------------------------------*/ SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Slave; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI2, &SPI_InitStructure);
/* Enable SPI2 RXNE interrupt */ SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, ENABLE); /* Enable SPI2 */ SPI_Cmd(SPI2, ENABLE); } |