2026-01-31 10:46 AM - last edited on 2026-02-02 2:02 AM by Andrew Neil
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
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--;
}
}
}Edited to apply source code formatting - please see How to insert source code for future reference.
2026-01-31 12:07 PM
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.
2026-02-02 1:41 AM
Hello @milindmishra87
The 0xFFs and clock activity after enabling SPI is normal behavior of the SPI master.. /CS does not stop the SPI peripheral from toggling SCK/MOSI; it only tells the flash when to pay attention.
To be sure there is no issue with your NOR flash, I recommend verifying the CPOL/CPHA, and half‑duplex direction bits and sharing your SPI register dump just before starting the transfer.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.