cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to establish communication between ST32ML4S9ZIT and MT25QL512ABB

Daniel Mosconi
Associate II

Hi,

I'm unable to establish communication between ST32ML4S9ZIT and MT25QL512ABB(NOR Flash) via Quad SPI.

The code has been generated by STM32CubeMX using OctoSPI configured in Quad mode, but I'm not able to establish communication with this NOR Flash.

It get stuck at the following line of the MX_OCTOSPI1_Init function:

"if (HAL_OSPI_AutoPolling(&hospi1, &cfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)"

the result is HAL_ERROR, because 

hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_SEQUENCE

I have configured the OctoSPI in following way in CubeMX:

/* OCTOSPI1 init function */
void MX_OCTOSPI1_Init(void)
{
  OSPIM_CfgTypeDef OSPIM_Cfg_Struct = {0};
  OSPI_AutoPollingTypeDef cfg = {0};
 
  hospi1.Instance = OCTOSPI1;
  hospi1.Init.FifoThreshold = 4;
  hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
  hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MICRON;
  hospi1.Init.DeviceSize = 25;
  hospi1.Init.ChipSelectHighTime = 3;
  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 = 32;
  hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
  hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;
  hospi1.Init.ChipSelectBoundary = 0;
  if (HAL_OSPI_Init(&hospi1) != HAL_OK)
  {
    Error_Handler();
  }
  OSPIM_Cfg_Struct.ClkPort = 2;
  OSPIM_Cfg_Struct.NCSPort = 2;
  OSPIM_Cfg_Struct.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
  if (HAL_OSPIM_Config(&hospi1, &OSPIM_Cfg_Struct, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
  {
    Error_Handler();
  }
  cfg.Match = 0;
  cfg.Mask = 0;
  cfg.MatchMode = HAL_OSPI_MATCH_MODE_AND;
  cfg.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;
  cfg.Interval = 0;
  if (HAL_OSPI_AutoPolling(&hospi1, &cfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_OSPI_AutoPolling_IT(&hospi1, &cfg) != HAL_OK)
  {
    Error_Handler();
  }
 
}

Thanks

1 REPLY 1
ASimo.3
Associate III

Did you ever figure this out?  I have a similar problem.