cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing calibration values with ICACHE enabled causes hard fault

Kilian Nötzold
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Sarra.S
ST Employee

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.

View solution in original post

1 REPLY 1
Sarra.S
ST Employee

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.