XiP STM32H750 changing flash latency for HAL_RCC_ClockConfig
Hi, on my board i`m running bootloader in internal flash of stm32h750 together with 2 QSPI NOR chips that store main program.
Bootloader starts and jumps to main program in QSPI, however
it get`s tricky when this function is called:
SystemClock_Config();Inside of it we can see HAL_RCC_ClockConfig function that causes hard fault if FLASH_LATENCY is set to default value (4). By trial and error I`ve figured out that it works with values that are >= 7.
void SystemClock_Config(void)
{
.
.
.
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
Error_Handler();
}
}Now the problem is that since HAL_RCC_ClockConfig function is autogenerated I would need to update this setting everytime I make some changes in .ioc file, setting it in user code won`t help because mentioned above function sets it back to default value.
HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency)
{
.
.
.
/* Increasing the CPU frequency */
if(FLatency > __HAL_FLASH_GET_LATENCY())
{
/* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
__HAL_FLASH_SET_LATENCY(FLatency);
/* Check that the new number of wait states is taken into account to access the Flash
memory by reading the FLASH_ACR register */
if(__HAL_FLASH_GET_LATENCY() != FLatency)
{
return HAL_ERROR;
}
}
.
.
.
/* Decreasing the number of wait states because of lower CPU frequency */
if(FLatency < __HAL_FLASH_GET_LATENCY())
{
/* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
__HAL_FLASH_SET_LATENCY(FLatency);
/* Check that the new number of wait states is taken into account to access the Flash
memory by reading the FLASH_ACR register */
if(__HAL_FLASH_GET_LATENCY() != FLatency)
{
return HAL_ERROR;
}
}
}Any Ideas how I can solve this?

