Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: acd52832_SAADC_Differential_input_2
Fork of acn_nrf52_saadc by
Diff: acd_nrf52_saadc.cpp
- Revision:
- 9:a1eacc3f0cbb
- Parent:
- 8:b4afe08821f5
- Child:
- 10:b763d9cfc063
--- a/acd_nrf52_saadc.cpp	Thu Sep 28 16:37:24 2017 +0000
+++ b/acd_nrf52_saadc.cpp	Fri Sep 29 11:12:03 2017 +0000
@@ -16,10 +16,11 @@
         // Do this for the first object only
         NRF_SAADC->ENABLE = 1;
         NRF_SAADC->RESULT.PTR =(uint32_t)data;  // Pass pointer to results buffer
+        calibrate();
     }
     if(channelCounter < 8){
-        NRF_SAADC->CH[channel].PSELP = analogIn;     
-        NRF_SAADC->CH[channel].CONFIG = 0x00020000; // reset
+        NRF_SAADC->CH[channel].PSELP = analogIn + 1;     
+        NRF_SAADC->CH[channel].CONFIG = 0x00021500; // reset
         channelCounter++;
         NRF_SAADC->RESULT.MAXCNT = channelCounter;
     }
@@ -30,11 +31,12 @@
         // Do this for the first object only
         NRF_SAADC->ENABLE = 1;
         NRF_SAADC->RESULT.PTR =(uint32_t)data;  // Pass pointer to results buffer
+        calibrate();
     }
     if(channelCounter < 8){
-        NRF_SAADC->CH[channel].PSELP = pPin;     
-        NRF_SAADC->CH[channel].PSELN = nPin;     
-        NRF_SAADC->CH[channel].CONFIG = 0x00125000; // differential  input, Gain 1
+        NRF_SAADC->CH[channel].PSELP = pPin + 1;     
+        NRF_SAADC->CH[channel].PSELN = nPin + 1;     
+        NRF_SAADC->CH[channel].CONFIG = 0x00121500; // differential  input, Gain 1
         channelCounter++;
         NRF_SAADC->RESULT.MAXCNT = channelCounter;
     }
    