From 501dba8f99734a61af97babb8182b5387a210981 Mon Sep 17 00:00:00 2001 From: Ureloc Date: Thu, 26 Oct 2017 07:15:44 +0200 Subject: [PATCH] Fixed using VDD as analog reference The analog gain is a bit confusing as the input range is calculated by dividing Vref by the gain not multiplying. Using VDD as ref results in an input range of (VDD/4)/gain therefore if a range of 0...VDD is needed gain must be 1/4 not 4 (check p363 of product spec) --- cores/nRF5/wiring_analog_nRF52.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/nRF5/wiring_analog_nRF52.c b/cores/nRF5/wiring_analog_nRF52.c index 8f4c3e79..e01b0b38 100644 --- a/cores/nRF5/wiring_analog_nRF52.c +++ b/cores/nRF5/wiring_analog_nRF52.c @@ -98,7 +98,7 @@ void analogReference( eAnalogReference ulMode ) switch ( ulMode ) { case AR_VDD4: saadcReference = SAADC_CH_CONFIG_REFSEL_VDD1_4; - saadcGain = SAADC_CH_CONFIG_GAIN_Gain4; + saadcGain = SAADC_CH_CONFIG_GAIN_Gain1_4; break; case AR_INTERNAL_3_0: saadcReference = SAADC_CH_CONFIG_REFSEL_Internal;