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

ADC Result not changing w/respect to Analog input

Hello,

I am trying to read data from nRF51422 ADC using SDK51 PCA10028 board downloaded with S130. I tried one of existing ADC with Softdevice examples, it seems to work for the most part but the data I am getting is always the same ( 0xA5).

The ADC initialization looks okay and I checked it with the Keil debugger, the values are set correctly. The ADC and timer interrupts work correctly. I also get correct ADC result when I change the prescaling input to: ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling which I get 0x344 for result.

I spent a lot of time looking here and on Github for similar problems/solutions to no avail. So far I tried analog inputs P0.00-P0.02, the result is constant for all cases even though the analog input voltage is either set to 0 or 3.3v. I don't know if this is DK problem or something else.

main.c

Parents
  • Hi Jay

    Your ADC configuration seems to be fine, except that you are sampling on analog input pin 0 which maps to pin P0.26 on the nRF51 IC, which is shared with the input from the low frequency 32kHz crystal, see section 2.2.1 in the nRF51822 PS v3.2. Try to sample from e.g. analog input pin 2, which is pin P0.01 instead, to see if you get better results.

    Update 5.8.2016 Below is an example which is ble_app_hrs with nRF51 ADC addon, which hopefully addresses what you are trying to do. The example uses the nrf_drv_adc driver. ADC sampling is triggered from the battery application timer. The ADC driver allocates buffer and throws an event to the application when the buffer is full. The ADC handler takes an average value from the buffer values and also calculates millivolts and battery percentage before transferring the results over BLE.

    ble_app_hrs_adc_battery_measurement.zip

Reply
  • Hi Jay

    Your ADC configuration seems to be fine, except that you are sampling on analog input pin 0 which maps to pin P0.26 on the nRF51 IC, which is shared with the input from the low frequency 32kHz crystal, see section 2.2.1 in the nRF51822 PS v3.2. Try to sample from e.g. analog input pin 2, which is pin P0.01 instead, to see if you get better results.

    Update 5.8.2016 Below is an example which is ble_app_hrs with nRF51 ADC addon, which hopefully addresses what you are trying to do. The example uses the nrf_drv_adc driver. ADC sampling is triggered from the battery application timer. The ADC driver allocates buffer and throws an event to the application when the buffer is full. The ADC handler takes an average value from the buffer values and also calculates millivolts and battery percentage before transferring the results over BLE.

    ble_app_hrs_adc_battery_measurement.zip

Children
Related