cancel
Showing results for 
Search instead for 
Did you mean: 

QSPI sends wrong instruction

Christian Pommer
Associate II

Dear Readers,

i try to connect to a LY68L6400 via Quad SPI. I manage without Problems to read the ID of the Chip, which i think means the communication is Working. When i try to write data (by Sending 0x38 as instruction) The instruction is changed to 0x3B adding to extra ones at the end. The ones also appear in the register. My Code is below. I am very happy over all Suggestions.

hqspi.Instance = QUADSPI;
  hqspi.Init.ClockPrescaler = 15;
  hqspi.Init.FifoThreshold = 5;
  hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
  hqspi.Init.FlashSize = 15;
  hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE;
  hqspi.Init.ClockMode = QSPI_CLOCK_MODE_3;
  hqspi.Init.FlashID = QSPI_FLASH_ID_1;
  hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
  if (HAL_QSPI_Init(&hqspi) != HAL_OK)
  {
    Error_Handler();
  }
	static QSPI_CommandTypeDef qspiCommand;
	qspiCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
	qspiCommand.Instruction = 0x38; //READ
	qspiCommand.AddressMode = QSPI_ADDRESS_4_LINES;
	qspiCommand.AddressSize = 3;
	qspiCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
	qspiCommand.Address = Address;
	qspiCommand.DataMode = QSPI_DATA_4_LINES;
	qspiCommand.DummyCycles = 8;
	qspiCommand.NbData = length;
	qspiCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
	qspiCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; 	// I have to set this
	qspiCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; 			// I have to set this
 
	if (HAL_QSPI_Command(&hqspi, &qspiCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
		printf("HAL_ERROR\n");
		return HAL_ERROR;
	}
	if (HAL_QSPI_Receive(&hqspi, Buffer, 100000) != HAL_OK)
	{
		printf("HAL_ERROR\n"); // Timeout after 5000mS
		return HAL_ERROR;
	}

2 REPLIES 2
Christian Pommer
Associate II

Ok i found the error allready.

qspiCommand.AddressSize = 3;

Should be

qspiCommand.AddressSize = QSPI_ADDRESS_24_BITS;

Glad you found it.

Not sure if this a global or local variable, but I'd generally recommend the latter, and implicitly clearing it so there's not random/holdover junk in it.

QSPI_CommandTypeDef qspiCommand = {0};

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