cancel
Showing results for 
Search instead for 
Did you mean: 

The QUADSPI module sent extra one clock to get data

Hughman0998
Associate

When I sent an SPI commnad to get the status from an SPI NAND, an extra clock was sent by the STM32F4.

I chedked the waveform with a logic analyzer.

An 8-bit command was sent to D0.

An 8-bit address was sent to D0.

There were 9 clocks sent by the controller to get data from D1.

I expected only 8 clocks.

The behavior of the SPI slave or SPI NAND was correct. It replied the 8-bit data normally. 

The board I used is NUCLEO-F412ZG.

The tool I use is STM32CubeIDE.

The code I worte was given below.

/////////////////////

QSPI_CommandTypeDef sCommand;

QSPI_AutoPollingTypeDef sConfig;

 

/* Configure automatic polling mode to wait for memory ready ------ */

sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;

sCommand.Instruction = READ_STATUS_REG_CMD;

sCommand.AddressMode = QSPI_ADDRESS_1_LINE;

sCommand.AddressSize= QSPI_ADDRESS_8_BITS;

sCommand.Address = addr;

sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;

sCommand.DataMode = QSPI_DATA_1_LINE;

sCommand.DummyCycles = 0;

sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;

sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;

sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

sCommand.NbData = 1;

 

//check the status automatically

sConfig.Match = match;

sConfig.Mask = mask;

sConfig.MatchMode = QSPI_MATCH_MODE_AND;

sConfig.StatusBytesSize = 1;

sConfig.Interval = 0x10;

sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE;

 

if (HAL_QSPI_AutoPolling(&hqspi, &sCommand, &sConfig, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

{

return HAL_ERROR;

}

 

return HAL_OK;

/////////////////////

SPI_CLK.png

4 REPLIES 4
PGump.1
Senior III

This looks like a classic case of the wrong CPOL and/ or CPHA setting...

 

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
TDK
Guru

I've changed your title to reflect that you're asking about QUADSPI, not SPI.

Not sure on the question. If you increase dummy cycles to 1, does the number of bits increase by 1 (to 2 extra)?

Might be something with auto polling. Does the same happen with HAL_QSPI_Command + HAL_QSPI_Receive?

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Evangelist III

Show initialization code.

Clear auto/local variables in a function as they can contain random junk.

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