2024-06-18 04:35 AM
hello
@SL2
I am configuring with QuadSPI Dual and encountering an issue where it remains in a busy state and does not resolve.
The circuit is not properly connected yet, so I am currently only testing the pin output.I want to output to Bank2 IO.
I initialized it as follows:
static void MX_QUADSPI_Init(void)
{
hxspi.Instance = QUADSPI;
hxspi.Init.ClockPrescaler = 255;
hxspi.Init.FifoThresholdByte = 1;
hxspi.Init.SampleShifting = XSPI_SAMPLE_SHIFTING_NONE;
hxspi.Init.MemorySize = 0;
hxspi.Init.ChipSelectHighTimeCycle = 1;//XSPI_CS_HIGH_TIME_1_CYCLE;
hxspi.Init.ClockMode = XSPI_CLOCK_MODE_3;
hxspi.Init.MemoryMode = HAL_XSPI_DUAL_MEM;//XSPI_DUALFLASH_ENABLE;
if (HAL_XSPI_Init(&hxspi) != HAL_OK)
{
Error_Handler();
}
}
XSPI_ResetChip();
HAL_Delay(2);
XSPI_AutoPollingMemReady();
XSPI_WriteEnable();
HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE);
XSPI_Configuration();
XSPI_AutoPollingMemReady();
while (1)
{
HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE);
HAL_XSPI_Transmit(&hxspi, QSP_DATA, 1000);
HAL_Delay(200);
}
When proceeding as described above, after the XSPI_AutoPollingMemReady function, unknown data is output and the system enters a busy state.
Even when I break in the IDE debug mode, data continues to be output on the oscilloscope.
It seems like the XSPI.c file wasn't generated correctly during CubeMX code generation. As a workaround, you copied the XSPI.c file from the STM32MP135DK example to use in your project.
Please fill in the contents of each function below.
Please review for any potentially problematic areas in the entire content.
Thank you.
Solved! Go to Solution.
2024-06-19 05:42 AM
Changing sCommand.DataLength to 0 in static uint8_t XSPI_WriteEnable(void) fixed the issue and it now functions correctly.
2024-06-18 04:35 AM
uint8_t XSPI_AutoPollingMemReady(void)
{
XSPI_RegularCmdTypeDef sCommand;
XSPI_AutoPollingTypeDef sConfig;
/* Configure automatic polling mode to wait for memory ready ------ */
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.Instruction = READ_STATUS_REG_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DataMode = XSPI_DATA_4_LINES;
sCommand.DummyCycles = 0;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
/* For auto polling mode status bytes size is same as DataLength */
sCommand.DataLength = 1;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
sConfig.MatchValue = 0x00;
sConfig.MatchMask = 0x01;
sConfig.MatchMode = XSPI_MATCH_MODE_AND;
sConfig.IntervalTime = 0x10;
sConfig.AutomaticStop = XSPI_AUTOMATIC_STOP_ENABLE;
ConfigCmd = sCommand;
if (HAL_XSPI_AutoPolling(&hxspi, &sConfig, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
uint8_t XSPI_ResetChip(void)
{
XSPI_RegularCmdTypeDef sCommand;
uint32_t temp = 0;
/* Erasing Sequence -------------------------------------------------- */
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.AddressWidth = XSPI_ADDRESS_24_BITS;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
sCommand.Instruction = RESET_ENABLE_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.Address = 0;
sCommand.DataMode = XSPI_DATA_NONE;
sCommand.DummyCycles = 0;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
if (HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}
for (temp = 0; temp < 0x2f; temp++) {
__NOP();
}
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.AddressWidth = XSPI_ADDRESS_24_BITS;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
sCommand.Instruction = RESET_MEMORY_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.Address = 0;
sCommand.DataMode = XSPI_DATA_NONE;
sCommand.DummyCycles = 0;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
if (HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
static uint8_t XSPI_WriteEnable(void)
{
XSPI_RegularCmdTypeDef sCommand;
XSPI_AutoPollingTypeDef sConfig;
/* Enable write operations ------------------------------------------ */
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.Instruction = WRITE_ENABLE_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DataMode = XSPI_DATA_4_LINES;//XSPI_DATA_NONE;
sCommand.DummyCycles = 0;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
/* For auto polling mode status bytes size is same as DataLength */
sCommand.DataLength = 1;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
if (HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
/* Configure automatic polling mode to wait for write enabling ---- */
sConfig.MatchValue = 0x02;
sConfig.MatchMask = 0x02;
sConfig.MatchMode = XSPI_MATCH_MODE_AND;
sConfig.IntervalTime = 0x10;
sConfig.AutomaticStop = XSPI_AUTOMATIC_STOP_ENABLE;
sCommand.Instruction = READ_STATUS_REG_CMD;
sCommand.DataMode = XSPI_DATA_4_LINES;
ConfigCmd = sCommand;
if (HAL_XSPI_AutoPolling(&hxspi, &sConfig, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
uint8_t XSPI_Configuration(void)
{
XSPI_RegularCmdTypeDef sCommand;
uint8_t test_buffer[4] = { 0 };
/*read status register*/
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.Instruction = READ_STATUS_REG_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DataMode = XSPI_DATA_4_LINES;
sCommand.DummyCycles = 0;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
sCommand.DataLength = 1;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
if (HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
// if (HAL_XSPI_Receive(&hxspi, test_buffer, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
// return HAL_ERROR;
// }
/*read configuration register*/
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.Instruction = READ_CFG_REG_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DataMode = XSPI_DATA_4_LINES;
sCommand.DummyCycles = 0;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
sCommand.DataLength = 1;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
if (HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
// if (HAL_XSPI_Receive(&hxspi, &(test_buffer[1]), HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
// return HAL_ERROR;
// }
test_buffer[0] |= 0x40; /* modify buffer to enable quad mode */
test_buffer[1] |= 0xC0; /* set dummy cycles */
sCommand.InstructionMode = XSPI_INSTRUCTION_4_LINES;
sCommand.AddressWidth = XSPI_ADDRESS_24_BITS;
sCommand.AlternateByteMode = XSPI_ALT_BYTES_NONE;
sCommand.DTRMode = XSPI_DTR_MODE_DISABLE;
sCommand.DelayHoldHalfCycle = XSPI_DHHC_ANALOG_DELAY;
sCommand.SIOOMode = XSPI_SIOO_INST_EVERY_CMD;
sCommand.Instruction = WRITE_STATUS_CFG_REG_CMD;
sCommand.AddressMode = XSPI_ADDRESS_NONE;
sCommand.DataMode = XSPI_DATA_4_LINES;
sCommand.DummyCycles = 0;
sCommand.DataLength = 2;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_7_4;
if (HAL_XSPI_Command(&hxspi, &sCommand, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
if (HAL_XSPI_Transmit(&hxspi, test_buffer, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
2024-06-19 05:42 AM
Changing sCommand.DataLength to 0 in static uint8_t XSPI_WriteEnable(void) fixed the issue and it now functions correctly.