2018-11-10 05:09 AM
Hi,
With helping of CubeMX I measure voltage on battery (ADC channel 0) using ADC in DMA mode. I also measure internal refference because my VDDA is not know in advance.
Once these 2 values are measured I need to convert the RAW data to mVolts.
I use datasheet formula using macro:
For getting VrefAnalogVoltage I use:
ADCVrefInternal=__LL_ADC_CALC_VREFANALOG_VOLTAGE(ADCVrefInternal,LL_ADC_RESOLUTION_12B);
The problem is that if I call the macro above I always end up in HardFault function. Missed I anything? Maybe there is problem with reading the calibration value stored there: (((uint32_t)(*VREFINT_CAL_ADDR)
And finally I would use this formula:
ADCResult=__LL_ADC_CALC_DATA_TO_VOLTAGE(ADCVrefInternal, ADCResult, LL_ADC_RESOLUTION_12B);
Thanks for support.
Jan.
2018-11-10 01:04 PM
It really looks like I can not read the VREFINT_CAL_ADDR from memory.
When I try this the Hard Fault occurs:
#define VREFINT_CAL_ADDR ((uint16_t*) (0x1FF800F8U))
uint16_t Vref=*(VREFINT_CAL_ADDR);
Where is the mistake?
Thank you! Jan.
2018-11-11 01:14 AM
No one had similar problem?
2018-11-11 10:35 PM
Which STM32L152 exactly? There are at least two different VREFINT_CAL addresses, depending on the particular model. Read out DBGMCU_IDCODE.
JW
2018-11-11 11:22 PM
I have STM32L152VBTxA LQFP100. ID code: 0x10186429
2018-11-12 01:53 AM
2018-11-12 02:16 AM
Thank you so much, Probably I linked wrong LL_Drivers.