cancel
Showing results for 
Search instead for 
Did you mean: 

SPI constantly sending Clock and OxFF over MOSI after enabling SPI in half duplex.

milindmishra87
Visitor

Hi,

I have been trying to communicate with an SPI peripheral (NOR Flash). I want to use SPI in half duplex mode. The problem is that as soon as enable the SPI peripheral I see SPI constantly sending OxFF over MOSI even though I have not written anything on the SPI DR register.

Pasting the screenshot of the Salea LA

Screenshot 2026-01-31 134429.png

Below is the simple SPI TX code

void SPI_SendData(uint8_t* Txdata, uint32_t len) {
    if((spi_dev->SR & TXE_FLAG)) {
      spi_dev->DR = *(uint8_t*)Txdata;
      Txdata++;
      len--;
    }

  if(!(spi_dev->CR1 & SPI_EN)) {
    spi_dev->CR1 |= SPI_EN;
  }
  while(len > 0) {
    // Wait for TXE FLAG
    if((spi_dev->SR & TXE_FLAG)) {
      spi_dev->DR = *(uint8_t*)Txdata;
      Txdata++;
      len--;
    }
  }
}
1 REPLY 1
TDK
Super User

In half duplex mode, you need to toggle between sending and receiving. When receiving, it is clocked constantly as shown in your logic analyzer traces.

If you feel a post has answered your question, please click "Accept as Solution".