cancel
Showing results for 
Search instead for 
Did you mean: 

QSPI HOLD remains asserted when switching from 1-line to 4-line mode

BHamm
Associate II

If I execute all OSPI commands with either DataMode set to HAL_OSPI_DATA_1_LINE or set to HAL_OSPI_DATA_4_LINES then everything behaves as expected. If I first execute a command with DataMode set to HAL_OSPI_DATA_1_LINE, then the Data[3]/HOLD line remains asserted when I attempt to execute any commands with DataMode set HAL_OSPI_DATA_4_LINES.

Why is the 1-line mode behavior not clearing when I instruct it to use 4-line data mode? The datasheet implies that the data mode should change for each phase (instructions, address, data) based on the command.

From application note AN5050: "It is recommended to reset the OCTOSPI peripheral before starting a configuration. This action also guarantees that the peripheral is in reset state." It does not clarify exactly what the reset procedure should be. I've tried clearing the OSPI CCR register (IMODE, ADMODE, ABMODE, and DMODE), calling HAL_OSPI_DeInit() then HAL_OSPI_Init(), and calling HAL_OSPIM_Config(). None have any impact on the the HOLD/D3 line, although HAL_OSPI_DeInit() does temporarily let HOLD/D3 go low.

Simplified code:

// Configuration  
 OSPI_HandleTypeDef ospiHandle = {
      .Instance = OCTOSPI1,
      .Init = {
         .FifoThreshold = 1,
         .DualQuad = HAL_OSPI_DUALQUAD_DISABLE,
         .MemoryType = HAL_OSPI_MEMTYPE_MACRONIX,
         .DeviceSize = 24,
         .ChipSelectHighTime = 2,
         .FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE,
         .ClockMode = HAL_OSPI_CLOCK_MODE_0,
         .WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED,
         .ClockPrescaler = 8,
         .SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE,
         .DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE,
         .ChipSelectBoundary = 0,
         .DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_BYPASSED,
         .MaxTran = 0,
         .Refresh = 0,
      },
   };
 
   uint8_t bytes[100];
 
  // 1-line data mode receive setup
   OSPI_RegularCmdTypeDef command = {0};
   command.FlashId            = self->config.OSPI_FlashID;
   command.OperationType      = HAL_OSPI_OPTYPE_COMMON_CFG;
   command.InstructionMode    = HAL_OSPI_INSTRUCTION_1_LINE;
   command.InstructionSize    = HAL_OSPI_INSTRUCTION_8_BITS;
   command.Instruction        = 0x05;
   command.DataMode           = HAL_OSPI_DATA_1_LINE;
   command.NbData             = 1;
   HAL_OSPI_Command(&ospiHandle, &command, COMMAND_TIMEOUT);
   HAL_OSPI_Receive(&ospiHandle, bytes, READ_REGISTER_TIMEOUT);
 
   // Data[3]/HOLD is now high
 
   // Another 1-line data mode receive
   OSPI_RegularCmdTypeDef command = {0};
   command.FlashId            = self->config.OSPI_FlashID;
   command.OperationType      = HAL_OSPI_OPTYPE_COMMON_CFG;
   command.InstructionMode    = HAL_OSPI_INSTRUCTION_1_LINE;
   command.InstructionSize    = HAL_OSPI_INSTRUCTION_8_BITS;
   command.Instruction        = 0x05;
   command.DataMode           = HAL_OSPI_DATA_1_LINE;
   command.NbData             = 1;
   HAL_OSPI_Command(&ospiHandle, &command, COMMAND_TIMEOUT);
   HAL_OSPI_Receive(&ospiHandle, bytes, READ_REGISTER_TIMEOUT);
 
   // Data[3]/HOLD will be pulled low at some point during this operation, but will go back high after
 
   // 4-line data mode receive
   OSPI_RegularCmdTypeDef command = {0};
   command.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
   command.FlashId = self->config.OSPI_FlashID;
   command.Instruction = 0xEB; // 4x  data read
   command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
   command.AddressSize = HAL_OSPI_ADDRESS_24_BITS;
   command.Address = 0;
   command.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
   command.DataMode =  HAL_OSPI_DATA_4_LINES;
   command.DummyCycles = 4;
   command.NbData = 100;
   HAL_OSPI_Command(&self->config.OspiHandle, &command, COMMAND_TIMEOUT);
   HAL_OSPI_Receive(&ospiHandle, bytes, READ_DATA_TIMEOUT);
 
   // Data[3]/HOLD remains high during this operation; values in the “bytes�? array; HOLD is not cleared by the command to put it into 4-line data mode

1 REPLY 1

This with your STM32U585 / W25Q128FV combo ?

The Winbond has been configure in 4-Pin mode (QE=1, not QPI) ?

The HOLD/RESET likely has an internal pull-up on the Winbond side.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..