SAADC differential input setup. With EPD display.
Dependencies: GDEP015OC1 acn_nrf52_saadc adc52832_common
Diff: main.cpp
- Revision:
- 0:04520242cfef
- Child:
- 1:41e296b93414
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 28 14:43:03 2017 +0000 @@ -0,0 +1,46 @@ +/* + * Example to demonstrate usage of the nrf52's SAADC in differential working\ + * mode. + * + * Made by Jurica Resetar @ aconno + * jurica_resetar@yahoo.com + * More info @ aconno.de + * + * All rights reserved + * + */ + + + +#include "mbed.h" +#include "acd_nrf52_saadc.h" + +#define PRINT (1) + +#if PRINT + #include "nrf52_uart.h" + NRF52_UART uart(p25, p26, Baud9600); + char buffer[255]; + #define SEND(...) {uint8_t len = sprintf(buffer, __VA_ARGS__); uart.send(buffer, len);} +#else + #define SEND(...) +#endif + + +NRF52_SAADC analogIn; + +int main(void){ + float voltageDiff; + int16_t rawData; + // Configure SAADC + analogIn.addChannel(5); // Set VDD as source to SAADC + analogIn.calibrate(); // + + while(1){ + analogIn.updateData(); + rawData = analogIn.getData()[0]; + voltageDiff = (float)((3.6/512)*rawData); + SEND("Voltage differance is: %fV\r\n", voltageDiff); + //SEND("Raw data is: %d\n\r", rawData); + } +} \ No newline at end of file