cancel
Showing results for 
Search instead for 
Did you mean: 

QSPI external RAM

sabari1
Associate III

hi all,

i was trying to work with stm32u585 microcontroller and an external RAM IS66WVQ2M4DALL , which is a QSPI based RAM can work in 133Mhz.the RAM support DDR based data transfer. Here i am attaching my OSPI configuration 

  hospi1.Instance = OCTOSPI1;
  hospi1.Init.FifoThreshold = 1;
  hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
  hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_APMEMORY;
  hospi1.Init.DeviceSize = 20;
  hospi1.Init.ChipSelectHighTime = 1;
  hospi1.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
  hospi1.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
  hospi1.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
  hospi1.Init.ClockPrescaler = 2;
  hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
  hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_ENABLE;
  hospi1.Init.ChipSelectBoundary = 0;
  hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_USED;
  hospi1.Init.MaxTran = 0;
  hospi1.Init.Refresh = 320;
  if (HAL_OSPI_Init(&hospi1) != HAL_OK)
  {
    Error_Handler();
  }
  sOspiManagerCfg.ClkPort = 1;
  sOspiManagerCfg.DQSPort = 1;
  sOspiManagerCfg.NCSPort = 1;
  sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
  if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
  {
    Error_Handler();
  }
  HAL_OSPI_DLYB_Cfg_Struct.Units = 0;
  HAL_OSPI_DLYB_Cfg_Struct.PhaseSel = 0;
  if (HAL_OSPI_DLYB_SetConfig(&hospi1, &HAL_OSPI_DLYB_Cfg_Struct) != HAL_OK)
  {
    Error_Handler();
  }

here i am confused about selecting hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_APMEMORY;

#define HAL_OSPI_MEMTYPE_MICRON              ((uint32_t)0x00000000U)                                         /*!< Micron mode       */
#define HAL_OSPI_MEMTYPE_MACRONIX            ((uint32_t)OCTOSPI_DCR1_MTYP_0)                                 /*!< Macronix mode     */
#define HAL_OSPI_MEMTYPE_APMEMORY            ((uint32_t)OCTOSPI_DCR1_MTYP_1)                                 /*!< AP Memory mode    */
#define HAL_OSPI_MEMTYPE_MACRONIX_RAM        ((uint32_t)(OCTOSPI_DCR1_MTYP_1 | OCTOSPI_DCR1_MTYP_0))         /*!< Macronix RAM mode */
#define HAL_OSPI_MEMTYPE_HYPERBUS            ((uint32_t)OCTOSPI_DCR1_MTYP_2)                                 /*!< Hyperbus mode     */

from some forums its get to know that this is based on the data order D0/D1 or D1/D0 from the datasheet of my memory ship the timing diagram look like 

sabari1_0-1738740509990.png

so here what option i need to take. and planning to work with memory mapped mode . here when i tried with read and write my read and write is corrupting  can anybody check with my configuration 

@tjaekel 

1 REPLY 1
KDJEM.1
ST Employee

Hello @sabari1;

 

The memory type depends on the D0/D1 ordering: The micron (and compatible memories) use D0/D1 Ordering while Macronix (and compatible memories) use D1/D0 data ordering and Macronix RAM (and compatible memories)  use D1/D0 ordering with dedicated address mapping.

If you have a memory different from Micron and Macronix you simply need to look at the data ordering in the memory datasheet and then select the one that matches it in STM32 OSPI configuration.

But, when using the QSPI mode, any memory type can be chosen if it is supported by the Octo-SPI interface. The memory type does not affect the functionality for the QSPI. The memory type has no impact in Quad-SPI mode.

Please take a look at AN5050 table8. and precisely note 2.

KDJEM1_0-1738743792925.png

I recommend you to try to decrease the OCTOSPI frequency. Please take a look at DS13086 table143. and table 144. to check the maximum OCTOSPI frequency.

KDJEM1_1-1738744112560.png

KDJEM1_2-1738744130275.png

KDJEM1_3-1738744158297.png

 

Thank you.

Kaouthar

 

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.