Skip to main content
JAN R
Associate III
November 10, 2018
Question

STM32L152 ADC- Can not read from address 0x1FF800F8U

  • November 10, 2018
  • 6 replies
  • 1156 views

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.

    This topic has been closed for replies.

    6 replies

    JAN R
    JAN RAuthor
    Associate III
    November 10, 2018

    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
    JAN RAuthor
    Associate III
    November 11, 2018

    No one had similar problem?

    waclawek.jan
    Super User
    November 12, 2018

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

    JW

    JAN R
    JAN RAuthor
    Associate III
    November 12, 2018

    I have STM32L152VBTxA LQFP100. ID code: 0x10186429

    waclawek.jan
    Super User
    November 12, 2018

    0690X000006CM98QAG.png

    JAN R
    JAN RAuthor
    Associate III
    November 12, 2018

    Thank you so much, Probably I linked wrong LL_Drivers.