nRF5 SDK v12.3.0
ADC Example
This information applies to the nRF51 Series only.

The ADC Example demonstrates the use of the analog-to-digital converter (ADC) peripheral in a simple way. It uses the ADC driver.

The example initializes ADC and constantly samples the analog input 2 on pin 1. The output is printed on UART. The example is event-driven, which means that no busy loops are used. Therefore, the CPU can be turned off during inactive periods.

The provided event handler is called by the driver when a new sampling result is available. The result is enclosed in a proper text message and transmitted via UART. The main loop of the example is empty. It is used only to put the CPU into low-power consumption mode.

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\adc

Testing

Test the ADC HAL Example application by performing the following steps:

  1. Compile and program the application.
  2. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  3. Check the output and observe that:
    1. After reset, basic information about the example is output on UART.
    2. When the example is running, the ADC samples analog input 2 and outputs the result value on UART.

Documentation feedback | Developer Zone | Subscribe | Updated