Hello everyone,
We are using the nrf52840 Dev Kit (PCA10056 1.1.0 2019.19 683465548)
SDK Version: 15.3
OS: Fedora
When we are generating a 1V voltage our adc returns values between [260, 280]. We use this function to convert it into µV:
#define ADC_REF_VOLTAGE_IN_MILLIVOLTS 600 #define ADC_RES_10BIT 1024 #define ADC_PRE_SCALING_COMPENSATION 6 int32_t adc_result_to_uv(int16_t adc_value) { int32_t adc_uv = ((((adc_value) * 600000) / 1024) * 6); return adc_uv; }We get values around 940 000 µV instead of 1 000 000µV.
We tried to change the resolution into 14 BIT like above:
#define ADC_REF_VOLTAGE_IN_MILLIVOLTS 600 #define ADC_RES_14BIT 16384 #define ADC_PRE_SCALING_COMPENSATION 6 int32_t adc_result_to_uv(int16_t adc_value) { int32_t adc_uv = ((((adc_value) * 600000) / 16384) * 6); return (int32_t) adc_uv; }
But we get strange results:
- adc_value between [4200, 4400]
- adc_uv around -631554 µV
We don't know what we are doing wrong and how to get a better precision...
Any ideas?