cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072 - Hard Fault when reading from System Memory

bjerman
Associate II
Posted on July 20, 2015 at 19:47

Hi.

I'm looking for some help with the STM32F072.

Q: What are you trying to do?

A: I'm trying to read the factory measured voltage of the bandgap voltage reference in order to calculate the VDD as exactly as possible. As per the STM32F072xx datasheet:

The internal voltage reference provides a stable (bandgap) voltage output for the ADC. Vrefint is internally connected to the ADC_IN17 input channel. The precise voltage of Vrefint is individually measured for each part by ST during producton test and stored in the system memory area. It is accesible in read only mode.

The datasheet also provides the memory addresses for the calibration values:

Vrefint_cal: 0x1FFF F7BA - 0x1FFF F7BB

Q: So what's the problem?

A: I'm trying to read the values at these registers but I'm consistently getting the system Hard Fault error.

Q: How are you reading the data?

A: I'm not doing anything special. I'm simply trying this:

float vref = *((float *) 0x1FFFF7BA);

 

Is there anything that I'm missing? Any help would be greatly appreciated.
6 REPLIES 6
Posted on July 20, 2015 at 20:03

It's not a 32-bit float. It's a 16-bit unsigned word.

The Cortex-M0 is intolerant of unaligned memory reads/writes. 0xA is not divisible by 4

unsigned short vref = *((unsigned short *) 0x1FFFF7BA);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bjerman
Associate II
Posted on July 20, 2015 at 20:17

Thank you, that makes sense. I'm still learning and am really grateful for your help.

I have one more question, though. With your help, I can successfully read the data at the address (the value is 1546 decimal), but I can't figure out what does it stand for. I was expecting the measured value of the band gap reference in volts. Do you perhaps know how to properly convert this value?

I can't find any information in the datasheet or the reference manual.

[EDIT]

Ah, yes, well, I guess I should learn how to read. It says in the description of the data content:

Raw data acquired at a temperature of 30°C (+/- 5 °C), Vdda = 3.3V (+/- 10 mV).

I guess that means that 1546 is the quantization value (a fraction of the Vdda voltage) corresponding to the 1.2 V bandgap. The fixed, ST provided precision value here is the Vdda voltage at 3.3 V.

So the proper value of my bandgap is (1546*3,3)/4096 = 1,246 V.

This is it. Thank you for your help.
Posted on July 20, 2015 at 20:25

STM32F072xx datasheet rev.2, 3.10.2 Internal voltage reference (VREFINT):

Raw data acquired at a temperature of 30 °C (+-5 °C), VDDA= 3.3 V (+-10 mV)

i.e. it's the value you are supposed to read from the internal ADC at the given VDDA and given temperature. Thus the reference voltage is 3.3V * VREFINT / ADC_full_span.

JW
bjerman
Associate II
Posted on July 20, 2015 at 20:26

Yes, thank you, I figured it out just seconds after you posted (see my second-to-last reply).

Thank you both.

Posted on July 20, 2015 at 20:49

Note that the DISCO boards are usually 3.0V, not 3.3V

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bjerman
Associate II
Posted on July 20, 2015 at 21:11

Yeah, this is exactly why the ST measurement is useful to me. I'm working on a custom board which could have different power supply voltages (3.0V, 3.3V, 3.6V), dependent on the regulator which could sourced with a certain batch.

In short, I can't rely on fixed, known Vdd as it's done in examples, but I do need to make a absolute voltage measurement with a certain degree of accuracy. The ST factory reference measurement proved really useful here, since I now do a Vdd voltage calibration on every powerup based off the bandgap reference.