void hanzireadone(u8 *pBuffer,u8 qu,u16 ReadAddr)
{
unsigned char i;
GPIO_SetBits(GPIOB,GPIO_Pin_10);
hanzi_cs_l;
while(SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE)==RESET);
SPI_I2S_SendData(SPI2,qu);
green_led_on;
while(SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE)==RESET);
green_led_off;
SPI_I2S_SendData(SPI2,ReadAddr>>8);
while(SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE)==RESET);
SPI_I2S_SendData(SPI2,ReadAddr);
for(i=0;i<32;i++)
{
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
*(pBuffer+i)=SPI_I2S_ReceiveData(SPI2);
}
hanzi_cs_h;
}
到这里就死循环了,好象TXE一直为0,SPI2好象没有发送,好象发送缓冲区中一直有数据
green_led_on;
while(SPI_I2S_GetFlagStatus(SPI2,SPI_I2S_FLAG_TXE)==RESET);
MOSI 和MISO和SCK电压在0。8V左右,不知道什么原因?? |