Skip to main content
Explorer II
December 19, 2024
Solved

Accessing calibration values with ICACHE enabled causes hard fault

  • December 19, 2024
  • 1 reply
  • 682 views

Hello,
Any access to the calibration memory addresses of the analogue temperature sensor or the internal reference causes a hard fault if ICACHE is enabled.
Here is an example:

ui16Temp = __HAL_ADC_CALC_VREFANALOG_VOLTAGE(0x0BF0, ADC_RESOLUTION_12B);
MX_ICACHE_Init ();
ui16Temp = __HAL_ADC_CALC_VREFANALOG_VOLTAGE(0x0BF0, ADC_RESOLUTION_12B);

Stepping in the debugger, we can see that the first operation gives the expected result. After enabling the ICACHE, we end up in a hard fault.
I pass the fixed value 0x0BF0 just for testing purposes to skip all the ADC related stuff.
My workaround is to store the calibration values in a global variable before enabling the ICACHE and use the variable instead of the memory addresses. Is there any other solution to this?

Took me a few days to figure this out. Hope it helps someone.

    This topic has been closed for replies.
    Best answer by Sarra.S

    Hello @Kilian Nötzold

    Please refer to this KB article: How to avoid a HardFault when ICACHE is enabled on... - STMicroelectronics Community 

    1 reply

    Sarra.SAnswer
    ST Employee
    December 19, 2024