cancel
Showing results for 
Search instead for 
Did you mean: 

Quad SPI Mode 1-1-4 Read Problem

Mike_d
Associate

Hi,

I'm using OCTOSPI in Mode Quad SPI on a STM32H563ZIT6.  I'm having issues when reading Serial Flash data with a 1-1-4 (6Bh) read, 1-1-4 (32h) write is working fine. Also 1-1-1 read and 1-1-2 read also work fine.  The serial flash is IS25LP032D.  I have verified QE=1 and DummyCycles = 8 before issuing the read command. The 1-1-4 read has more problems if data is FF FF FF versus 01 02 03. 1-1-1 and 1-1-2 reads have no problem.  Here is the config (Cube MX) and 1-1-4 read function. I have the SPI bus running at 1MHz

  hospi1.Instance = OCTOSPI1;
  hospi1.Init.FifoThresholdByte = 1;
  hospi1.Init.MemoryMode = HAL_XSPI_SINGLE_MEM;
  hospi1.Init.MemoryType = HAL_XSPI_MEMTYPE_MICRON;
  hospi1.Init.MemorySize = HAL_XSPI_SIZE_64MB;
  hospi1.Init.ChipSelectHighTimeCycle = 1;
  hospi1.Init.FreeRunningClock = HAL_XSPI_FREERUNCLK_DISABLE;
  hospi1.Init.ClockMode = HAL_XSPI_CLOCK_MODE_0;
  hospi1.Init.WrapSize = HAL_XSPI_WRAP_NOT_SUPPORTED;
  hospi1.Init.ClockPrescaler = 249;
  hospi1.Init.SampleShifting = HAL_XSPI_SAMPLE_SHIFT_HALFCYCLE;
  hospi1.Init.DelayHoldQuarterCycle = HAL_XSPI_DHQC_DISABLE;
  hospi1.Init.ChipSelectBoundary = HAL_XSPI_BONDARYOF_NONE;
  hospi1.Init.DelayBlockBypass = HAL_XSPI_DELAY_BLOCK_BYPASS;
  hospi1.Init.Refresh = 0;

 

uint8_t buf_rx[16] = {0};
is25_read_114(0x1000, buf_rx, sizeof(buf_rx));
int is25_read_114(uint32_t address, uint8_t *buffer, uint32_t length)
{
	XSPI_RegularCmdTypeDef cmd = {0};
	HAL_StatusTypeDef result;



	// Require quad mode for 0x6B
	if(quad_enable == QUAD_DISABLE)
		return -1;

	memset(&cmd, 0, sizeof(cmd));

	// 1-1-4 Fast Read Quad Output (0x6B)
	cmd.Instruction        = 0x6B;
	cmd.OperationType      = HAL_XSPI_OPTYPE_COMMON_CFG;
	cmd.InstructionMode    = HAL_XSPI_INSTRUCTION_1_LINE;
	cmd.InstructionWidth   = HAL_XSPI_INSTRUCTION_8_BITS;

	// Address on 1 line (1-1-4)
	cmd.AddressMode        = HAL_XSPI_ADDRESS_1_LINE;
	cmd.AddressWidth       = HAL_XSPI_ADDRESS_24_BITS;
	cmd.Address            = address;

	// No mode/alternate bytes for 0x6B
	cmd.AlternateBytesMode  = HAL_XSPI_ALT_BYTES_NONE;
	cmd.AlternateBytesWidth = 0;
	cmd.AlternateBytes      = 0;

	// Data on 4 lines
	cmd.DataMode           = HAL_XSPI_DATA_4_LINES;
	cmd.DataLength         = length;

	// ISSI Fast Read Dual Output uses 8 dummy clocks by default.
	cmd.DummyCycles        = 8;

	cmd.IOSelect           = HAL_XSPI_SELECT_IO_3_0;

	result = HAL_XSPI_Command(hqspi, &cmd, HAL_XSPI_TIMEOUT_DEFAULT_VALUE);
	if(result != HAL_OK)
	{
		return -2;
	}

	result = HAL_XSPI_Receive(hqspi, buffer, HAL_XSPI_TIMEOUT_DEFAULT_VALUE);
	if(result != HAL_OK)
	{
		return -3;
	}

	return 0;
}

 Thanks,

-Mike

1 REPLY 1
KDJEM.1
ST Employee

Hello @Mike_d and welcome to the community;

 

What is the OCTOSPI frequency?

-> The 1-1-4 read has more problems if data is FF FF FF versus 01 02 03.

Can you please share the reading results for different data FF FF FF and 01 02 03?

 

Thank you.

Kaouthar

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.