According to this post, and this GitHub source file, in the nRF51 chip's mbed implementation:
- The ADC reference voltage is 1/3 power supply
- read_u16() seems to return
NRF_ADC->RESULT
NRF_ADC->RESULT
maximum possible value would be 0x3FF, when ADC input equals to ADC reference voltage.
From an experiment I just ran, I observed the following
- At ADC input of ~897mV,
read_u16()
returns ~0x011a, or 282 decimal. - At ADC input of ~520mV,
read_u16()
returns ~0x00b9, or 185 decimal. - Leaving the ADC input pin floating,
read_u16()
returns ~0x00af, or 175 decimal.
Using linear approximation with the first two data points, at read_u16()
value of 0x03FF, the ADC input should be >4V.
If using only one of those data points with the assumption that at 0V input, read_u16()
returns 0, then 0x03FF still means a voltage >3V.
These numbers certainly cannot be 1/3 power supply! What could be going on here? Am I misunderstanding something?
Just in case this fact is the reason to the problem: To conduct my experiment, I use a (1M - 220k) voltage divider to supply 1/6 of VDD or 5V to the analog input.
On another note, according to mbed's Analog In
reference and the AnalogIn.h header file, read_u16()
returns "input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]". This description sucks. But at the same time it doesn't seem to be what nRF51's implementation of the function is returning. Is there any comment on this?