2019-10-14 01:06 PM
I’m trying to get my STM32H743 to communicate with a Cypress S25FL128S.
I want to change the state of the Configuration register bit 1 from the default of zero to a one.
I want to use the HAL_QSPI API to perform this write but I’m confused on how to add two byte command sequence.
Instruction WWR = 0x01
QSPI_CommandTypeDef my_qspiCommand;
my_qspiCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
my_qspiCommand.Instruction = 0x01;
my_qspiCommand.AddressMode = QSPI_ADDRESS_NONE;
my_qspiCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
my_qspiCommand.DataMode = QSPI_DATA_1_LINE;
my_qspiCommand.DummyCycles = 0;
my_qspiCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
my_qspiCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
my_qspiCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
HAL_QSPI_Command(QSPIHandle, &my_qspiCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE);
How do structure this command to add my two byte command sequence?
Thanks
The following from QSPI spec on how the data write should be formatted:
Solved! Go to Solution.
2019-10-14 01:20 PM
uint8_t data[2];
/* Read two bytes --------------------------- */
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = CMD;
sCommand.AddressMode = QSPI_ADDRESS_NONE;
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 = sizeof(data);
if (HAL_QSPI_Command(&QSPIHandle, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
if (HAL_QSPI_Receive(&QSPIHandle, &data, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
/* Write two bytes --------------------------- */
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = CMD;
sCommand.AddressMode = QSPI_ADDRESS_NONE;
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 = sizeof(data);
if (HAL_QSPI_Command(&QSPIHandle, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
if (HAL_QSPI_Transmit(&QSPIHandle, &data, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
2019-10-14 01:20 PM
uint8_t data[2];
/* Read two bytes --------------------------- */
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = CMD;
sCommand.AddressMode = QSPI_ADDRESS_NONE;
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 = sizeof(data);
if (HAL_QSPI_Command(&QSPIHandle, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
if (HAL_QSPI_Receive(&QSPIHandle, &data, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
/* Write two bytes --------------------------- */
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = CMD;
sCommand.AddressMode = QSPI_ADDRESS_NONE;
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 = sizeof(data);
if (HAL_QSPI_Command(&QSPIHandle, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
if (HAL_QSPI_Transmit(&QSPIHandle, &data, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return 0;
}
2019-10-15 06:53 AM
thanks!