cancel
Showing results for 
Search instead for 
Did you mean: 

DeInitialization of the QSPI peripheral

AShetty
Visitor

I intend to use the following API to deinitialize the OCTOSPI peripheral which I am using in the Quad SPI mode on the STM32H563 board: 

 

HAL_StatusTypeDef HAL_XSPI_DeInit(XSPI_HandleTypeDef *hxspi)
{
  HAL_StatusTypeDef status = HAL_OK;

  /* Check the XSPI handle allocation */
  if (hxspi == NULL)
  {
    status = HAL_ERROR;
    /* No error code can be set as the handler is null */
  }
  else
  {
    /* Disable XSPI */
    HAL_XSPI_DISABLE(hxspi);

    /* Disable free running clock if needed : must be done after XSPI disable */
    CLEAR_BIT(hxspi->Instance->DCR1, XSPI_DCR1_FRCK);
	  
	//hxspi->Instance->DCR1 = 0x05; //TODO remove afterwards

#if defined (USE_HAL_XSPI_REGISTER_CALLBACKS) && (USE_HAL_XSPI_REGISTER_CALLBACKS == 1U)
    if (hxspi->MspDeInitCallback == NULL)
    {
      hxspi->MspDeInitCallback = HAL_XSPI_MspDeInit;
    }

    /* De-initialize the low level hardware */
    hxspi->MspDeInitCallback(hxspi);
#else
    /* De-initialize the low-level hardware */
    HAL_XSPI_MspDeInit(hxspi);
#endif /* (USE_HAL_XSPI_REGISTER_CALLBACKS) && (USE_HAL_XSPI_REGISTER_CALLBACKS == 1U) */

    /* Reset the driver state */
    hxspi->State = HAL_XSPI_STATE_RESET;
  }

  return status;
}

However, I observed that the peripheral registers are not getting set to their reset values. Instead, all the registers seem to have the same erroneous value. (It turns out that the value is the same as in the DCR1). 

I have also observed that if I have a breakpoint just before (line 31)

HAL_XSPI_MspDeInit(hxspi);

and step over it no such problem occurs and all registers contain their accurate reset values.

What is going wrong?

 

1 REPLY 1

> However, I observed that the peripheral registers are not getting set to their reset values. Instead, all the registers seem to have the same erroneous value. (It turns out that the value is the same as in the DCR1).

That probably indicates that the given peripheral has clock disabled in RCC (as is the reset state).

JW