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:
- 2:1e7d6ab5b04b
- Parent:
- 1:2d6e904c6843
- Child:
- 3:fcada8b3b567
--- a/acd_nrf52_saadc.cpp Wed Aug 23 07:28:42 2017 +0000
+++ b/acd_nrf52_saadc.cpp Wed Aug 23 07:59:02 2017 +0000
@@ -7,21 +7,22 @@
NRF_SAADC->RESULT.MAXCNT = 1;
NRF_SAADC->RESULT.PTR =(uint32_t)dataPointer;
NRF_SAADC->CH[0].PSELP = 9; // Input positive pin is VDD = 9
+ NRF_SAADC->TASKS_CALIBRATEOFFSET = 1;
+ while(!NRF_SAADC->EVENTS_CALIBRATEDONE);
}
NRF52_SAADC::~NRF52_SAADC(){
-
+ NRF_SAADC->ENABLE = 0;
}
void NRF52_SAADC::getData(){
NRF_SAADC->TASKS_START = 1;
while(!NRF_SAADC->EVENTS_STARTED);
NRF_SAADC->TASKS_SAMPLE = 1;
- while(!NRF_SAADC->EVENTS_END);
while(!NRF_SAADC->EVENTS_RESULTDONE);
while(!NRF_SAADC->EVENTS_DONE);
- //if(NRF_SAADC->RESULT.AMOUNT == 0);
- wait_us(20);
+ while(!NRF_SAADC->EVENTS_END);
+ while(NRF_SAADC->STATUS == 1); // while conversion is is progress
NRF_SAADC->TASKS_STOP = 1;
while(!NRF_SAADC->EVENTS_STOPPED);
}
