cancel
Showing results for 
Search instead for 
Did you mean: 

How to format HAP_QSPI API write a two byte QSPI command sequence?

TBibe
Associate II

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:

0690X00000AqLaiQAF.png

0690X00000AqLasQAF.png

0690X00000AqLaxQAF.png

1 ACCEPTED SOLUTION

Accepted Solutions

 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;

 }

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

View solution in original post

2 REPLIES 2

 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;

 }

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

thanks!