Question
uint8_t TI_TDC1000_SPIByteReadReg(uint8_t addr) { uint8_t read_byte,inst; uint8_t dummy = 0x00; inst = TDC1000_READ_BIT
Posted on February 21, 2017 at 09:33
Dear all,
here is my code to read spi data:
uint8_t TI_TDC1000_SPIByteReadReg(uint8_t addr)
{ uint8_t read_byte,inst; uint8_t dummy = 0x00; inst = TDC1000_READ_BIT & addr; // for read make sure bit6 is 0 //GPIO_ResetBits(TI_TDC1000_CSn_PORT ,TI_TDC1000_CSn_PIN); // CS enablewhile (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE)== RESET);
SPI_SendData(SPI1, inst);while (SPI_GetFlagStatus(SPI1, SPI_FLAG_TXE)== RESET);
SPI_SendData(SPI1, dummy); /* Wait to receive a byte */ while (SPI_GetFlagStatus(SPI1, SPI_FLAG_RXNE) == RESET); /* Return the byte read from the SPI bus */ read_byte = SPI_ReceiveData(SPI1);return read_byte;
}
I using oscilloscope and see that the data is read = 0x45, but in my code
read_byte alway = 0xFF, I think somewhere wrong when spi recieve data.
