Skip to main content
Kilian Nötzold
Associate III
December 19, 2024
Solved

Accessing calibration values with ICACHE enabled causes hard fault

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.
Sarra.SBest answer
ST Employee
December 19, 2024

Hello @Kilian Nötzold, 

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

1 reply

Sarra.SBest answer
ST Employee
December 19, 2024

Hello @Kilian Nötzold, 

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.