cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 ADC- Can not read from address 0x1FF800F8U

JAN R
Associate III

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.

6 REPLIES 6
JAN R
Associate III

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.

JAN R
Associate III

No one had similar problem?

Which STM32L152 exactly? There are at least two different VREFINT_CAL addresses, depending on the particular model. Read out DBGMCU_IDCODE.

JW

JAN R
Associate III

I have STM32L152VBTxA LQFP100. ID code: 0x10186429

0690X000006CM98QAG.png

JAN R
Associate III

Thank you so much, Probably I linked wrong LL_Drivers.