nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ADC HAL Example

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

The example initializes ADC and constantly samples the analog input on pin 2. 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 ADC IRQ handler is called when a new sampling result is available, to store the result in a buffer. The UART event handler is used to manage serial communication by filling the transmission buffer with the string to be sent. The main loop of the example is empty. It is used only to put the CPU into low-power consumption mode.

The name of the example is adc_simple_pca10028. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder: <InstallFolder>\examples\peripheral\adc_simple

Testing

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

  1. Compile and program the application.
  2. Start a COM listener like PUTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 38.400
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: RTS/CTS
  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.