Skip to main content
martin2399
Associate II
January 27, 2017
Question

Hard fault when accessing STM32L0 calibration values

Posted on January 27, 2017 at 11:39

Hi,

When accessing some calibration registers, I get a hard fault. It might be due to unaligned access.

Is the '

stm32l0xx_ll_adc.h,

V1.7.0' correct?

The 'VREFINT_CAL_ADDR' works correctly.

'TEMPSENSOR_CAL1_ADDR' and 'TEMPSENSOR_CAL2_ADDR' do not...

/* ADC internal channels related definitions */
/* Internal voltage reference VrefInt */
#define VREFINT_CAL_ADDR ((uint16_t*) ((uint32_t)0x1FF80078U)) 
/* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
#define VREFINT_CAL_VREF ((uint32_t) 3000U)
 /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
/* Temperature sensor */
#define TEMPSENSOR_CAL1_ADDR ((uint16_t*) ((uint32_t)0x1FF8007AU)) 
/* Internal temperature sensor, address of parameter TS_CAL1: On STM32L0, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
#define TEMPSENSOR_CAL2_ADDR ((uint16_t*) ((uint32_t)0x1FF8007EU))
 /* Internal temperature sensor, address of parameter TS_CAL2: On STM32L0, temperature sensor ADC raw data acquired at temperature 130 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
#define TEMPSENSOR_CAL1_TEMP (( int32_t) 30)
 /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
#define TEMPSENSOR_CAL2_TEMP (( int32_t) 130)
 /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
#define TEMPSENSOR_CAL_VREFANALOG ((uint32_t) 3000U)
 /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

BR Martin

    This topic has been closed for replies.

    2 replies

    martin2399
    Associate II
    January 27, 2017
    Posted on January 27, 2017 at 13:25

    '

    uint16_t' was defined as '

    unsigned int

    ', which caused the pointer to be treated as a 32bit pointer.

    When defining 

    '

    uint16_t' as 'unsigned short', it is correctly handled as 16bit pointer by the compiler.

    And it all works!

    Nesrine M_O
    Associate
    January 27, 2017
    Posted on January 27, 2017 at 13:33

    Hi

    Jorgensen.Martin

    ,

    Thank you for posting your findings and how you fixed the issue, it is good to hear that it was solved.

    -Nesrine-