VREFINT - sporadic false(?) readings
Using a STM32F091 board, I set up the ADC to:
- sample at the longest selectable sampling time (239.5 cycles)
- clock source is the internal 14 MHz RC osc
- resolution 12 bit
- sequence of all available channels incl. vrefint
At startup, there is a slight deviation: I set up the ADC to only sample VERFINT, take a lot of samples and average them; from that, calculate Vdda based on the formula in the reference manual, and store that value in a higher precision format, to calculate all the other voltages with during normal operation of the firmware.
Then I set the channel sequence to all channels, as said above.
The VREFINT channel is also captured as part of the sequence to, regularly, roughly monitor whether the 3V3 supply voltage is still OK.
During operation, when the ADC sequence is being continuously triggered by software, I make the following observations:
- all channels' values but one stay in their +/- deviation of a few percent from the measured rail's nominal value
- only the VREFINT value has a lot stronger deviations
- it is on point most of the time
- but every few seconds I get a value that's about 26% lower than expected
- when this wrong value comes, it stays pretty close to an ADC value of 2042 or so vs. the factory-calibrated one of 1536, the converted-back Vdda would be 2.465V instead of 3.3V
- I checked my conversion code: it stays correct for all legal ADC values, no number overflow or such things.
- I don't see these events on the oscilloscope, i.e. I don't see a real Vdda glitch (of that magnitude anyway, there is some switching noise in the +/-100mV range)
- as all other channels do not show a simultaneous glitch in their value curves over time, even though they should, as they all should be affected by a glitching VDDA = VREF, I therefore conclude this must be an artifact of some sort
If nobody objects to this logic, the question now would be: What / where is this artifact?
It shouldn't be too low sampling time, it is already the longest possible.
I have read the part of the ADC chapter in the reference again, also the errata sheet, and found nothing I might have overlooked that pertains to this.
Edit:
Ok, I forgot one thing: For the regular voltages' channels , I had (software) 8x averaging, and this Vrefint monitoring that I added recently, uses the raw last ADC value for that channel to convert it back to Vdda.
Disabling the averaging for the regular voltages now changed the picture a bit, but it's not less weird: Now *some* of the channels also have a "last error timestamp" (milsec resolution from systick) that is aligned with the last Vdda error (i.e. out of +/-10% bounds).
While other channels, after letting this run for 15 minutes, still only have timestamps from a few 100msec after boot, where it's expected to be stabilizing.
So: I do now see this on some channels besides Vrefint/Vdda, but not on others, and nothing special on the oscilloscope. All channels get captured in the same loop by the same code, the only special treatment is that the Vrefint values was taken from a buffer with last samples instead of with averaged ones. And which channels those are that get affected seems to stay the same.
I.e. before disabling averaging, the also affected channel's errors had been "averaged away" before. Using that as solution and ignoring the cause seems not a good idea.
Interesting seems the pattern of the affected channel numbers:
0 no, 1 no, 2 yes, 3 yes, 4 no, 5 no, 6 yes (not tracking beyond that in the test, but seems like 2x no, 2x yes, 2x no, ...)
