Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
This came in via email from gcohler, but I thought it may make sense to post here since the documentation for the ADC functionality is very limited:
We’re confused about the situation with reference voltage for the ADC, so I was hoping you could point me in the right direction.
Three things I’m confused about:
The API for SetReferenceVoltage(pin, voltage).
I believe (but am not sure) that, when called, the API takes a measurement of the pin specified, then computes the ratio between the raw ADC value and the number of millivolts specified to create a conversion factor between the raw ADC value and the millivolts value. And then saves that conversion factor for future use when adcRead() is called.
In other words, it is purely a software thing, and that it does not actually use that pin as the external hardware reference voltage for the ADC operation.
I believe (but am not sure) that there is at least one internal voltage reference inside the chip. But from the limited docs I can’t be sure. And there may be more than one.
If for example, I wanted to use the 1.2V core voltage as the reference, is that possible? Is there an API to select this? There are three bullets that talk about different impedances based on different voltage ranges. So that implies that there are three different references that I can use: VDD, 2.4 and Vcore.
If I call the SetReferenceVoltage API (for example with P15), does that make P15 an external reference for the ADC in a hardware sense? I’m thinking no, but not sure.
The different ADC Modes (table 1). Are these really just different sample and hold rates? So if I go to low-frequency sampling, I get better precision. Or is there more to these modes. There isn’t really any description of what the modes mean.
Thanks very much for any light that you can shed on this. I have a customer that wants to use 1.2V as the reference. Hence my curiosity.
And included the following understanding that I think would be helpful to others:
My current understanding:
The API for adcCalibrate(voltage, pin). – I named this wrong, it was adcCalibrate()
When called, the API takes a measurement of the pin specified, then computes the ratio between the raw ADC value and the number of millivolts specified to create a conversion factor between the raw ADC value and the millivolts value. And then saves that conversion factor for future use when adcRead() is called.
It also selects the hardware reference voltage for the ADC.
Beside the normal pin numbers that can be used, there are two other “key words”
ADC_INPUT_VDDIO – use VDDIO as an internal reference voltage
ADC_INPUT_VDD_CORE – use VDD core as the internal reference voltage.
There are three internal voltage references inside the chip. VDD, VDDIO, VDD_Core. By default, it uses VDD.
If I call the adcCalibrate API (for example with P15), that makes P15 an external reference for the ADC in a hardware sense.
There likely is at least a third keyword (maybe ADC_INPUT_VDD) for using VDD as the internal reference. But I didn't see it in the other posts. There's likely a .h file around with all these symbols defined.