summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-07-09 15:38:21 -0700
committerChromeBot <chrome-bot@google.com>2013-07-09 18:56:36 -0700
commitd67f83a63cc0a03994a2cc5c0565c7b51f773816 (patch)
tree65b4c8b8b866fea008c5d2a47070bada75488471
parent3bc27f0627637cae6e4edb8cd26716d46e5e67d2 (diff)
downloadchrome-ec-d67f83a63cc0a03994a2cc5c0565c7b51f773816.tar.gz
Use sample averaging on ADC to increase accuracy
The AC adapter detection isn't measuring the expected values, most likely because we're not providing enough current for the ADC circuitry to sample. This tells the ADC to take 64 samples for every reading and average them together. That seems to fix it. BUG=chrome-os-partner:19594 BRANCH=none TEST=manual To test, use a scope to probe the voltage pin 6 of the AC adapter connector. Compare that with the measured result from the ADC, by using the EC console's "adc" command. Before this change: Adapter Probed(mV) ADC(mV) error 45W 469 415 11.5% 65W 600 530 11.6% 90W 794 701 11.7% After this change: Adapter Probed(mV) ADC(mV) error 45W 469 452 3.6% 65W 600 590 1.6% 90W 794 773 2.6% Close enough. Change-Id: I5ab5526934a5a2711969a90a26631d54c7863da7 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/61346 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/lm4/adc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/chip/lm4/adc.c b/chip/lm4/adc.c
index eb6f640680..8e17854104 100644
--- a/chip/lm4/adc.c
+++ b/chip/lm4/adc.c
@@ -229,6 +229,9 @@ static void adc_init(void)
task_enable_irq(LM4_IRQ_ADC0_SS2);
task_enable_irq(LM4_IRQ_ADC0_SS3);
+ /* 2**6 = 64x oversampling */
+ LM4_ADC_ADCSAC = 6;
+
/* Initialize ADC sequencer */
for (i = 0; i < ADC_CH_COUNT; ++i)
lm4_adc_configure(adc_channels + i);