boards/feather-m0: Correct ADC Settings #21508
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
The current ADC settings set the reference to the internal 1V reference with a x1 gain. This means that the maximum voltage that can be measured with any analog input is 1V, which is usually not sufficient for most applications.
Therefore the default value is changed to use the external VDDA input, which is 3.3V (internally divided by 2) and the gain to x1/2. This allows to measure voltages up to VDDA on any analog input.
Testing procedure
You can run the
tests/periph/adc
example with an external voltage source connected. You should see that withmaster
, the ADC values max out at about 1V (or 2V for the battery input).I connected a 0.8V voltage to the BAT input, which has a 1/2 resistor divider.
master
: The values should be 0.8/1.0 * 0.5 * {256, 1024, 4096, 65536} = {102, 410, 1638, 26214} on ADC_LINE(6)):This PR: The values should be: 0.8/3.3 * 0.5 * {256, 1024, 4096, 65536} = {31, 124, 496, 7944} on ADC_LINE(6)):
Issues/PRs references
Found in #21022.
The ADC configuration was set when the Feather-M0 was introduced in #7510 and never changed since.