cancel
Showing results for 
Search instead for 
Did you mean: 

Strange delay on QSPI using 4 data lines

Taxara
Associate III

Hi all,

Currently i'm reading and writing to external flash using the QSPI peripheral. All data i write is received correctly but there seems to be a "unnecessary" delay in both writing and reading QSPI.

Sequence start with command 0x34 (page program)

Followed by 32bits of address

So far so good. Then it starts transmitting data using 4 lines. Here a delay is introduced between every set of 2 clock cycles (see attached picture). Does anyone know where this delay comes from or how i can solve it?

Kind regards,

Taxara

QSPI_CommandTypeDef command;
 
command.InstructionMode = QSPI_INSTRUCTION_1_LINE;
command.Instruction = 0x34;
command.AddressSize = QSPI_ADDRESS_32_BITS;
command.AddressMode = QSPI_ADDRESS_1_LINE;
 
command.Address = address;
 
command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
command.AlternateBytes = QSPI_ALTERNATE_BYTES_NONE;
command.AlternateBytesSize = QSPI_ALTERNATE_BYTES_NONE;
 
command.DummyCycles = 0;
command.DataMode = QSPI_DATA_4_LINES;
command.NbData = 256;
 
command.DdrMode = QSPI_DDR_MODE_DISABLE;
command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
 
if (HAL_QSPI_Command(&hqspi, &command, HAL_QSPI_TIMEOUT_DEFAULT_VALUE)
		!= HAL_OK)
	return QSPI_ERR;
 
if (HAL_QSPI_Transmit(&hqspi, buf, HAL_QSPI_TIMEOUT_DEFAULT_VALUE)
		!= HAL_OK)
	return QSPI_ERR;

0693W00000JNP7xQAH.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Taxara
Associate III

Ok, so after trying a few things i've got it to work by adding DMA to it. Added DMA1 CH5 to the QSPI peripheral in cubemx and altered the code just a little, see below;

// ADDED:
 
bool transmissionInProgress = false;
 
void HAL_QSPI_TxCpltCallback(QSPI_HandleTypeDef *hqspi)
{
  transmissionInProgress = false;
}
 
.....
 
if (HAL_QSPI_Command(&hqspi, &command, HAL_QSPI_TIMEOUT_DEFAULT_VALUE)
		!= HAL_OK)
	return QSPI_ERR;
 
transmissionInProgress = true;
if (HAL_QSPI_Transmit_DMA(&hqspi, buf)
		!= HAL_OK)
	return QSPI_ERR;
 
	while(transmissionInProgress);  // To keep it a blocking function

Hopefully it will be useful for someone.

Kind regards,

Taxara

View solution in original post

3 REPLIES 3

Not sure

Would however recommend clearing auto/local variables in subroutines to ensure they don't have random junk in them, as this can have all kind of odd behaviour as it OR's things together to construct writes to the QSPI peripheral registers.

QSPI_CommandTypeDef command = {0};

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

Thanks for the answer, it did not solve the issue unfortunately but non the less I've added it since its definitely an improvement.

Ps adding DMA solved this issue. ill post it below.

Taxara
Associate III

Ok, so after trying a few things i've got it to work by adding DMA to it. Added DMA1 CH5 to the QSPI peripheral in cubemx and altered the code just a little, see below;

// ADDED:
 
bool transmissionInProgress = false;
 
void HAL_QSPI_TxCpltCallback(QSPI_HandleTypeDef *hqspi)
{
  transmissionInProgress = false;
}
 
.....
 
if (HAL_QSPI_Command(&hqspi, &command, HAL_QSPI_TIMEOUT_DEFAULT_VALUE)
		!= HAL_OK)
	return QSPI_ERR;
 
transmissionInProgress = true;
if (HAL_QSPI_Transmit_DMA(&hqspi, buf)
		!= HAL_OK)
	return QSPI_ERR;
 
	while(transmissionInProgress);  // To keep it a blocking function

Hopefully it will be useful for someone.

Kind regards,

Taxara