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

How to get multi ADC data?

I hope to use a acceleration sensor with nRF51822 dev kit. So I should use three ADC input. I tested getting one ADC data using adc_simple example(Keil_v5/ARM/Pack/NordicSemiconductor/nRF_Examples/11.0.0-2alpha/peripheral/adc_simple). But I don't know how to use multi ADC interrupt handler.

  • Hi

    Please look at the ble_app_uart_adc_scan_mode example available on Nordic's Github page. Scan mode means that the ADC samples on multiple pins. There is some documentation provided when you click on the ble_app_uart_adc_scan_mode folder. Specifically look at how multiple inputs are configured in the adc_config function and how samples are handled in the adc_event_handler callback function.

  • Thank you for answering me. I downloaded and tried it but I got errors like below.

    *** Using Compiler 'V5.06 (build 20)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'nrf51422_xxac_s130'
    compiling main.c...
    ..\..\..\main.c(19): error:  #5: cannot open source input file "nordic_common.h": No such file or directory
      #include "nordic_common.h"
    ..\..\..\main.c: 0 warnings, 1 error
    compiling bsp_btn_ble.c...
    ..\..\..\..\..\bsp\bsp_btn_ble.h(32): error:  #5: cannot open source input file "ble.h": No such file or directory
      #include "ble.h"
    ..\..\..\..\..\bsp\bsp_btn_ble.c: 0 warnings, 1 error
    compiling bsp.c...
    ..\..\..\..\..\bsp\boards.h(15): error:  #5: cannot open source input file "nrf_gpio.h": No such file or directory
      #include "nrf_gpio.h"
    ..\..\..\..\..\bsp\bsp.c: 0 warnings, 1 error
    compiling ble_advertising.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\ble\ble_advertising\ble_advertising.c": No such file or directory
    ..\..\..\..\..\..\components\ble\ble_advertising\ble_advertising.c: 0 warnings, 1 error
    compiling ble_conn_params.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\ble\common\ble_conn_params.c": No such file or directory
    ..\..\..\..\..\..\components\ble\common\ble_conn_params.c: 0 warnings, 1 error
    compiling ble_advdata.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\ble\common\ble_advdata.c": No such file or directory
    ..\..\..\..\..\..\components\ble\common\ble_advdata.c: 0 warnings, 1 error
    compiling ble_nus.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\ble\ble_services\ble_nus\ble_nus.c": No such file or directory
    ..\..\..\..\..\..\components\ble\ble_services\ble_nus\ble_nus.c: 0 warnings, 1 error
    compiling app_uart_fifo.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\uart\app_uart_fifo.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\uart\app_uart_fifo.c: 0 warnings, 1 error
    compiling ble_srv_common.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\ble\common\ble_srv_common.c": No such file or directory
    ..\..\..\..\..\..\components\ble\common\ble_srv_common.c: 0 warnings, 1 error
    compiling nrf_delay.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\delay\nrf_delay.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\delay\nrf_delay.c: 0 warnings, 1 error
    compiling nrf_drv_gpiote.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\gpiote\nrf_drv_gpiote.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\gpiote\nrf_drv_gpiote.c: 0 warnings, 1 error
    compiling nrf_drv_common.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\common\nrf_drv_common.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\common\nrf_drv_common.c: 0 warnings, 1 error
    compiling nrf_drv_adc.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\adc\nrf_drv_adc.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\adc\nrf_drv_adc.c: 0 warnings, 1 error
    compiling nrf_drv_uart.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\uart\nrf_drv_uart.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\uart\nrf_drv_uart.c: 0 warnings, 1 error
    compiling pstorage.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\pstorage\pstorage.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\pstorage\pstorage.c: 0 warnings, 1 error
    compiling nrf_drv_ppi.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\ppi\nrf_drv_ppi.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\ppi\nrf_drv_ppi.c: 0 warnings, 1 error
    compiling app_button.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\button\app_button.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\button\app_button.c: 0 warnings, 1 error
    compiling nrf_drv_timer.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\drivers_nrf\timer\nrf_drv_timer.c": No such file or directory
    ..\..\..\..\..\..\components\drivers_nrf\timer\nrf_drv_timer.c: 0 warnings, 1 error
    compiling app_error.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\util\app_error.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\util\app_error.c: 0 warnings, 1 error
    compiling app_error_weak.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\util\app_error_weak.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\util\app_error_weak.c: 0 warnings, 1 error
    compiling app_fifo.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\fifo\app_fifo.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\fifo\app_fifo.c: 0 warnings, 1 error
    compiling app_timer.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\timer\app_timer.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\timer\app_timer.c: 0 warnings, 1 error
    compiling fstorage.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\fstorage\fstorage.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\fstorage\fstorage.c: 0 warnings, 1 error
    compiling app_util_platform.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\util\app_util_platform.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\util\app_util_platform.c: 0 warnings, 1 error
    compiling nrf_assert.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\util\nrf_assert.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\util\nrf_assert.c: 0 warnings, 1 error
    compiling nrf_log.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\util\nrf_log.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\util\nrf_log.c: 0 warnings, 1 error
    compiling retarget.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\libraries\uart\retarget.c": No such file or directory
    ..\..\..\..\..\..\components\libraries\uart\retarget.c: 0 warnings, 1 error
    compiling RTT_Syscalls_KEIL.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\external\segger_rtt\RTT_Syscalls_KEIL.c": No such file or directory
    ..\..\..\..\..\..\external\segger_rtt\RTT_Syscalls_KEIL.c: 0 warnings, 1 error
    compiling SEGGER_RTT.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT.c": No such file or directory
    ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT.c: 0 warnings, 1 error
    compiling SEGGER_RTT_printf.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT_printf.c": No such file or directory
    ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT_printf.c: 0 warnings, 1 error
    compiling softdevice_handler.c...
    "no source": Error:  #5: cannot open source input file "..\..\..\..\..\..\components\softdevice\common\softdevice_handler\softdevice_handler.c": No such file or directory
    ..\..\..\..\..\..\components\softdevice\common\softdevice_handler\softdevice_handler.c: 0 warnings, 1 error
    ".\_build\nrf51422_xxac_s130.axf" - 3 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed:  00:00:02
    

    I located the example folder at "C:\Keil_v5\ARM\Pack\NordicSemiconductor\nRF_Examples\11.0.0-2.alpha\ble_peripheral\ble_app_uart_adc_scan_mode".

    And actually I hope to test multi ADC(for acceleration sensor) based with "C:\Keil_v5\ARM\Pack\NordicSemiconductor\nRF_Examples\11.0.0-2.alpha\peripheral\adc_simple" this sample, if it is possible.

  • I only installed NodrdicSemiconductor::nRF_DeviceFamilyPack, NodrdicSemiconductor::nRF_Drivers, NodrdicSemiconductor::nRF_Examples, NodrdicSemiconductor::nRF_Libraries packs after install Keil uVision5

  • Well, I removed and add again Drivers and Libraries, and modified project option-C/C++-Include Paths. I still have some errors and be fixing it.

  • Hi

    The example is meant for SDK 11.0.0, but I can see you use SDK 11.0.0-2.alpha. Try it out using SDK 11.0.0

Related