This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

trouble reading ADC on nrf51422

I am trying to perform a simple ADC measurement using polling rather than using an interrupt. I have looked at examples and read the ADC section in the reference manual, but I am still not having luck getting this to work.

I have added a zip file containing the ADC code module and some log output.

The problem I am experiencing is that the result is always a constant value (0x313), but the voltage at the AINx pin is changing. The voltage at the AIN2 pin is 2.45 V when the battery monitor circuit is enabled (GPIO pin 28 = 1) and 0 V when the monitor circuit is disabled.

Likewise, the SENS1 and SENSE2 circuits are both enabled when GPIO pin 7 = 1. When the circuits are enabled, the measured voltage at the AIN3 and AIN5 inputs are both at 810 mV. When those circuits are disabled, the voltage drops to 3 mV.

But in all cases, the result I get is 0x313. I am sure that there must be something wrong with the software, but I have scrutinized it and it looks nearly identical to the examples, except for the polling instead of interrupt operation.

Note, I am not using a soft device. I am also not doing any GPIO configuration on the AINx inputs that I am using.

Is there something else required for the ADC to operate properly (e.g. a system clock setting, AINx inputs need a GPIO configuration, etc.)?

Thanks for any help you can provide.

--ken

adc_test.zip

Parents Reply Children
No Data
Related