The QUADSPI module sent extra one clock to get data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-23 8:35 PM - last edited on ‎2024-09-24 6:21 AM by TDK
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;
/////////////////////
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-23 11:06 PM
This looks like a classic case of the wrong CPOL and/ or CPHA setting...
Kind regards
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-24 6:26 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-24 6:37 AM
Please see the posting tips for how to properly post source code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-24 6:58 AM
Show initialization code.
Clear auto/local variables in a function as they can contain random junk.
Up vote any posts that you find helpful, it shows what's working..
