2024-07-22 05:12 AM
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?
2024-07-22 05:27 AM
> 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
2024-07-23 03:58 AM
I don't think it's an RCC issue.
I can use OCTOSPI after initialization and the bit corresponding to OCTOSPI in AHB4EN register of RCC is getting cleared when the deinitialization function executes. But, the value of the registers start showing accurate values only when I initialize again.