cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767 QSPI Flash Not Writing First Byte (S25FL256S)

MADHU2
Associate III

Hi everyone,

I'm using an STM32F767 with an S25FL256S NOR flash over QSPI in indirect mode (HAL driver).

I'm trying to write the string "HELLO" at address 0x000000, but after programming and reading, I always get: FF 45 4C 4C 4F → "ELLO".

The first byte is always 0xFF. All other bytes are written and read correctly.

 

What I’ve already done:

  • Verified Flash ID: 01 20 18 (correct)

  • Erased the sector before writing

  • Using 0x02 Page Program in 1-1-1 mode

  • Set SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD

  • Set FIFO threshold = 1

  • Using indirect mode (HAL_QSPI_Command() + HAL_QSPI_Transmit())

  •  

  • Test Code:
    char tx[] = "HELLO";
    QSPI_PageProgram(0x000000, (uint8_t*)tx, strlen(tx) + 1);
    QSPI_ReadData(0x000000, rx, strlen(tx) + 1);

    Why is the first byte not being written?

1 REPLY 1
MHoll.2
Senior III

Accoding to the S25FL256S Datasheet the 0x13 read command needs a 32 Bit Address, but You are sending only 24 Bit.

MHoll2_1-1752328889322.png

 

/*------------------------------------------------------------
  QSPI_ReadData
  Reads data starting at the given 24-bit address using the Read Data command (0x03).
  Datasheet reference: Section 11.4.1 (Normal Read).
------------------------------------------------------------*/
HAL_StatusTypeDef QSPI_ReadData(uint32_t address, uint8_t *pData, uint32_t Size)
{
    sCommand.Instruction     = CMD_READ_DATA;
    sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
    sCommand.Address         = address;
    sCommand.AddressMode     = QSPI_ADDRESS_1_LINE;
    sCommand.AddressSize     = QSPI_ADDRESS_24_BITS;
    sCommand.DataMode        = QSPI_DATA_1_LINE;
    sCommand.DummyCycles     = 0;  // Normal read does not require dummy cycles
    sCommand.NbData          = Size;

    if(HAL_QSPI_Command(&hqspi, &sCommand, HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
        return HAL_ERROR;

    return HAL_QSPI_Receive(&hqspi, pData, HAL_QSPI_TIMEOUT_DEFAULT_VALUE);
}