For the MPC5643L, analog to digital conversion, I don't find a clear statement about the reference voltage the ADC uses and which to relate the digital result register readings to:
I understand the MCU reference manual such that the analog supply voltage is the reference voltage at the same time and that this voltage can be chosen as 3.3 V or 5 V. If so, the reference voltage would depend on the external circuitry and for my TRK-USB-MPC5643L it would be 3.3 V.
On the other hand mentions the reference manual the internal analog source VREG_1.2V that is connected to channel 10 of boths ADCs. No further explanation is given on this signal source. The name indicates that it is a constant voltage source of 1.2 V. On my boards this signal is however measured as 1.3 V if I assume the reference voltage as said in the previous paragraph, i.e. as 3.3 V.
Is it correct that signal VREG_1.2V, ADC channel 10, should read as 1.2 V? If so, is it intended to relate all other channels to this reading, like:
const float factor = 1.2f / (float)(ADC_0.CDR[10].R & 0xfff0);
float u0 = factor * (float)(ADC_0.CDR[0].R & 0xfff0)
, u1 = factor * (float)(ADC_0.CDR[1].R & 0xfff0)
, ...
, u8 = factor * (float)(ADC_0.CDR[8].R & 0xfff0);
Is this the way to calibrate the ADC readings in Volt?
Thanks for your response, David, but my question is a bit different. I don't find clearly documented, what the reference voltage is: Is it the analog supply voltage of the MCU?
If so, the accuracy would be limited on my board (normal power supply IC) and I wonder if measuring the internal signal VREG_1.2V can help to improve it: If this is an internally generated (high accuracy) reference voltage then I could sample and convert it and use the result to scale the external ADC channels, too. This has been sketched in the lines of code above.
For 12 bit shifted 2 bits left conversion formula is (considering 5V reference):
ResultInMv = (5000*Result)/((2^12-1)<<2) = (5000*Result)/0x3FFC;
If your ADC reference is 3.3V, then it is:
ResultInMv = (3300*Result)/((2^12-1)<<2) = (3300*Result)/0x3FFC;
Yes, if you change reference voltage, digital code of converted 1.2V channel is different.