Skip to main content
July 23, 2023
Solved

MemoryMapped for w25q256 Octo SPI for Touchgfx

  • July 23, 2023
  • 3 replies
  • 2490 views

Hi, I used to work with a stm32h743 that had a QSPI, but now I work with a stm32h723zgt6 that has a OSPI. I don't know if I should continue with the MX_OCTOSPI1_Init function to use it for Memory Mapped for w25q256 program I wrote for Touch GFX.To use it for Touch GFX widgets 

ُThanks

This topic has been closed for replies.
Best answer by

Finally, I was able to get an answer. I will put the code at the end for those who need it

OSPI_RegularCmdTypeDef sCommand={0};
    OSPI_MemoryMappedTypeDef sMemMappedCfg={0};
 
    /* Enable Memory-Mapped mode-------------------------------------------------- */
/* Common Commands*/
    sCommand.OperationType      = HAL_OSPI_OPTYPE_READ_CFG; /* Read Configuration (Memory-Mapped Mode) */
    sCommand.FlashId            = HAL_OSPI_FLASH_ID_1; /* Set The OCTO SPI Flash ID */
    sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE; /* Disable Instruction DDR/DTR Mode */
    sCommand.AddressDtrMode      = HAL_OSPI_ADDRESS_DTR_DISABLE; /* Disable Address DDR/DTR Mode */
    sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE; /* Disable Data DDR/DTR Mode */
    sCommand.DQSMode            = HAL_OSPI_DQS_DISABLE; /* Disable Data Strobe */
    sCommand.SIOOMode          = HAL_OSPI_SIOO_INST_EVERY_CMD; /* SIOO Mode: Send instruction on every transaction */
    sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Disable Alternate Bytes Mode */
    sCommand.AlternateBytes = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes = 0 */
    sCommand.AlternateBytesSize = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes Size = 0 */
    sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE; /* Disable Alternate Bytes DDR/DTR Mode */
    sCommand.InstructionMode    = HAL_OSPI_INSTRUCTION_1_LINE; /* Instruction on a single line */
    sCommand.InstructionSize    = HAL_OSPI_INSTRUCTION_8_BITS; /* 8-bit Instruction */
    sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS; /* 24-bit Address */
    /* Instruction */
    sCommand.Instruction = 0xEC; /* What We Do? */
    /* Address */
    sCommand.AddressMode        = HAL_OSPI_ADDRESS_4_LINES; /* Define Address Lines: Address On Four Lines */
    sCommand.Address = 0; /* Byte Address */
    /* Data */
    sCommand.DataMode          = HAL_OSPI_DATA_4_LINES; /* Define Data Lines: Data On Four Lines */
    sCommand.DummyCycles        = 6; /* Bytes Send With No Data */
    sCommand.NbData            = 0; /* Bytes Send With Data */
 
    HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
 
    /* Initialize the program command */
/* Common Commands*/
    sCommand.OperationType      = HAL_OSPI_OPTYPE_WRITE_CFG; /* Write Configuration (Memory-Mapped Mode)) */
    sCommand.FlashId            = HAL_OSPI_FLASH_ID_1; /* Set The OCTO SPI Flash ID */
    sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE; /* Disable Instruction DDR/DTR Mode */
    sCommand.AddressDtrMode      = HAL_OSPI_ADDRESS_DTR_DISABLE; /* Disable Address DDR/DTR Mode */
    sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE; /* Disable Data DDR/DTR Mode */
    sCommand.DQSMode            = HAL_OSPI_DQS_DISABLE; /* Disable Data Strobe */
    sCommand.SIOOMode          = HAL_OSPI_SIOO_INST_EVERY_CMD; /* SIOO Mode: Send instruction on every transaction */
    sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Disable Alternate Bytes Mode */
    sCommand.AlternateBytes = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes = 0 */
    sCommand.AlternateBytesSize = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes Size = 0 */
    sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE; /* Disable Alternate Bytes DDR/DTR Mode */
    sCommand.InstructionMode    = HAL_OSPI_INSTRUCTION_1_LINE; /* Instruction on a single line */
    sCommand.InstructionSize    = HAL_OSPI_INSTRUCTION_8_BITS; /* 8-bit Instruction */
    sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS; /* 24-bit Address */
    /* Instruction */
    sCommand.Instruction = 0xEC; /* What We Do? */
    /* Address */
    sCommand.AddressMode        = HAL_OSPI_ADDRESS_1_LINE; /* Define Address Lines: Address On a Single Line */
    sCommand.Address = 0; /* Byte Address */
    /* Data */
    sCommand.DataMode          = HAL_OSPI_DATA_4_LINES; /* Define Data Lines: Data On Four Lines */
    sCommand.DummyCycles        = 6; /* Bytes Send With No Data */
    sCommand.NbData            = 0; /* Bytes Send With Data */
 
    HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
 
    /* Initialize Memory Mapped Command */
    sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE; /* Timeout counter disabled, nCS remains active */
 
    HAL_OSPI_MemoryMapped(&hospi1, &sMemMappedCfg);

3 replies

July 24, 2023

Hello again, I used to use the following code for Quad SPI and w25q256 and it worked perfectly, but now I don't know what code I should write for Octa SPI, please help me, I really need it

 

  QSPI_CommandTypeDef      s_command;
  QSPI_MemoryMappedTypeDef s_mem_mapped_cfg;
 
  /* Configure the command for the read instruction */
  s_command.InstructionMode   = QSPI_INSTRUCTION_1_LINE;
  s_command.Instruction       = 0xEC;//0xEC;
  s_command.AddressMode       = QSPI_ADDRESS_4_LINES;
  s_command.AddressSize       = QSPI_ADDRESS_32_BITS;  
  s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
  s_command.DataMode          = QSPI_DATA_4_LINES;
  s_command.DummyCycles       = 6;
  s_command.DdrMode           = QSPI_DDR_MODE_DISABLE;
  s_command.DdrHoldHalfCycle  = QSPI_DDR_HHC_ANALOG_DELAY;
  s_command.SIOOMode          = QSPI_SIOO_INST_EVERY_CMD;
 
  /* Configure the memory mapped mode */
  s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
  s_mem_mapped_cfg.TimeOutPeriod     = 0;
  
  HAL_QSPI_MemoryMapped(&hqspi, &s_command, &s_mem_mapped_cfg);
 
  HAL_NVIC_DisableIRQ(QUADSPI_IRQn);

 

July 25, 2023

Hi, do you have even one example ready for me to look at? So no one has worked with this part yet?

Best answer
July 25, 2023

Finally, I was able to get an answer. I will put the code at the end for those who need it

OSPI_RegularCmdTypeDef sCommand={0};
    OSPI_MemoryMappedTypeDef sMemMappedCfg={0};
 
    /* Enable Memory-Mapped mode-------------------------------------------------- */
/* Common Commands*/
    sCommand.OperationType      = HAL_OSPI_OPTYPE_READ_CFG; /* Read Configuration (Memory-Mapped Mode) */
    sCommand.FlashId            = HAL_OSPI_FLASH_ID_1; /* Set The OCTO SPI Flash ID */
    sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE; /* Disable Instruction DDR/DTR Mode */
    sCommand.AddressDtrMode      = HAL_OSPI_ADDRESS_DTR_DISABLE; /* Disable Address DDR/DTR Mode */
    sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE; /* Disable Data DDR/DTR Mode */
    sCommand.DQSMode            = HAL_OSPI_DQS_DISABLE; /* Disable Data Strobe */
    sCommand.SIOOMode          = HAL_OSPI_SIOO_INST_EVERY_CMD; /* SIOO Mode: Send instruction on every transaction */
    sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Disable Alternate Bytes Mode */
    sCommand.AlternateBytes = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes = 0 */
    sCommand.AlternateBytesSize = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes Size = 0 */
    sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE; /* Disable Alternate Bytes DDR/DTR Mode */
    sCommand.InstructionMode    = HAL_OSPI_INSTRUCTION_1_LINE; /* Instruction on a single line */
    sCommand.InstructionSize    = HAL_OSPI_INSTRUCTION_8_BITS; /* 8-bit Instruction */
    sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS; /* 24-bit Address */
    /* Instruction */
    sCommand.Instruction = 0xEC; /* What We Do? */
    /* Address */
    sCommand.AddressMode        = HAL_OSPI_ADDRESS_4_LINES; /* Define Address Lines: Address On Four Lines */
    sCommand.Address = 0; /* Byte Address */
    /* Data */
    sCommand.DataMode          = HAL_OSPI_DATA_4_LINES; /* Define Data Lines: Data On Four Lines */
    sCommand.DummyCycles        = 6; /* Bytes Send With No Data */
    sCommand.NbData            = 0; /* Bytes Send With Data */
 
    HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
 
    /* Initialize the program command */
/* Common Commands*/
    sCommand.OperationType      = HAL_OSPI_OPTYPE_WRITE_CFG; /* Write Configuration (Memory-Mapped Mode)) */
    sCommand.FlashId            = HAL_OSPI_FLASH_ID_1; /* Set The OCTO SPI Flash ID */
    sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE; /* Disable Instruction DDR/DTR Mode */
    sCommand.AddressDtrMode      = HAL_OSPI_ADDRESS_DTR_DISABLE; /* Disable Address DDR/DTR Mode */
    sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE; /* Disable Data DDR/DTR Mode */
    sCommand.DQSMode            = HAL_OSPI_DQS_DISABLE; /* Disable Data Strobe */
    sCommand.SIOOMode          = HAL_OSPI_SIOO_INST_EVERY_CMD; /* SIOO Mode: Send instruction on every transaction */
    sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Disable Alternate Bytes Mode */
    sCommand.AlternateBytes = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes = 0 */
    sCommand.AlternateBytesSize = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes Size = 0 */
    sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE; /* Disable Alternate Bytes DDR/DTR Mode */
    sCommand.InstructionMode    = HAL_OSPI_INSTRUCTION_1_LINE; /* Instruction on a single line */
    sCommand.InstructionSize    = HAL_OSPI_INSTRUCTION_8_BITS; /* 8-bit Instruction */
    sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS; /* 24-bit Address */
    /* Instruction */
    sCommand.Instruction = 0xEC; /* What We Do? */
    /* Address */
    sCommand.AddressMode        = HAL_OSPI_ADDRESS_1_LINE; /* Define Address Lines: Address On a Single Line */
    sCommand.Address = 0; /* Byte Address */
    /* Data */
    sCommand.DataMode          = HAL_OSPI_DATA_4_LINES; /* Define Data Lines: Data On Four Lines */
    sCommand.DummyCycles        = 6; /* Bytes Send With No Data */
    sCommand.NbData            = 0; /* Bytes Send With Data */
 
    HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
 
    /* Initialize Memory Mapped Command */
    sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE; /* Timeout counter disabled, nCS remains active */
 
    HAL_OSPI_MemoryMapped(&hospi1, &sMemMappedCfg);