2024-07-15 11:01 PM
Hello Community,
I am using 2 function calls
__LL_ADC_CALC_VREFANALOG_VOLTAGE();
__LL_ADC_CALC_TEMPERATURE_FLOAT();
My implementation:
uhADCxConvertedData_VrefAnalog_mVolt = __LL_ADC_CALC_VREFANALOG_VOLTAGE(aADCxConvertedData[1], LL_ADC_RESOLUTION_12B);
temperature = __LL_ADC_CALC_TEMPERATURE_FLOAT(uhADCxConvertedData_VrefAnalog_mVolt, aADCxConvertedData[2], LL_ADC_RESOLUTION_12B);
I am seeing the above macros not respond and there is a hard-fault whenever I call the above functions. Any help would be appreciated.
Thank you
Solved! Go to Solution.
2024-07-16 9:27 AM
@VThan.2 wrote:there is a hard-fault whenever I call the above functions.
So what have you done to debug the Hard Fault?
https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf
2024-07-16 1:36 AM
Have you checked this topic?
https://community.st.com/t5/stm32cubeide-mcus/ll-adc-calc-temperature-hardfaults-ts-cal1-ts-cal2-read-as-zero/td-p/77106
A macro should not result in a hardfault error unless it refers to an illegal memory location or divides by zero or something. What do you see when you debug the code and step through it? What are all the values? If this doesn't help you please upload your ioc file.
2024-07-16 9:22 AM
Hi @VThan.2
This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.
Regards,
Billy
2024-07-16 9:27 AM
@VThan.2 wrote:there is a hard-fault whenever I call the above functions.
So what have you done to debug the Hard Fault?
https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf
2024-07-16 10:52 PM
Thank you this worked.
2024-07-17 12:55 AM
What was the problem? How did you fix it?
2025-04-02 1:03 PM
I am getting the same issue. It looks like 0x08FFF814 is not a valid address.
2025-09-22 7:46 AM
I am also seeing this exact problem with STM32H573.
I see a hard fault just when reading TS_CAL1 with this code:
Bit 30 (FORCED) = 1 → This means a configurable fault (like bus/memory/usage fault) escalated to HardFault.
Other bits are 0 → not a vector table read fault.
So: the real cause is in CFSR, not in HFSR.
The CFSR is 32 bits, split into three sub-registers:
[31:16] UsageFault Status (UFSR)
[15:8] BusFault Status (BFSR)
[7:0] MemManage Fault Status (MMFSR)
Let’s decode 0x8200:
Binary: 1000 0010 0000 0000
Bits [15:8] = 0x82 → BusFault Status = 1000 0010
So BFSR bits:
Bit 7 (BFARVALID) = 1 → BFAR holds the faulting address.
Bit 1 (PRECISERR) = 1 → Precise data bus error.
Others = 0.
Thus: a precise bus fault occurred while accessing BFAR address.
No MemManage or UsageFault bits are set.
That’s exactly the TEMPSENSOR_CAL1_ADDR you pasted earlier.
So: the fault was triggered when the CPU tried to read the calibration constant at 0x08FFF814.
===
However, if I connect to the device using stm32programmer, I can see those addresses are written:
Is there a requirement to enable a specific clock or power domain to read these registers?
2025-09-22 8:02 AM
... I also just worked out why...
In this example linked below, there is a function MPU_Config which makes the area of flash containing trims un-cacheable. Adding this function results in no faults accessing the trims.