Solved
SPI TXE flag set early
- July 17, 2023
- 5 replies
- 2234 views
Hi,
I m testing SPI TXE flag with the following code:
void TestSPI(void)
{
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
SPI_I2S_SendData(SPI3, 0);
while (!SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE));
SPI_I2S_SendData(SPI3, 0);
while (!SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE));
GPIO_SetBits(GPIOA, GPIO_Pin_4);
}
The SPI is set to work with 16 bits.
Checking the pins on oscilloscope (see picture attached with yellow for GPIOA 4, blue for SCLK, purple for MOSI), you can see GPIOA pin 4 going high before the second half word is fully sent.
Would someone know why the second TXE flag is set while transmitting the second half-word?
Thank you.