1# SAADC simple non-blocking {#saadc_simple_non_blocking} 2 3The sample demonstrates a simple functionality of the nrfx_saadc driver operating in the non-blocking mode. 4 5## Requirements 6 7The sample supports the following development kits: 8 9| **Board** | **Support** | 10|---------------------|:-----------:| 11| nrf52dk_nrf52832 | Yes | 12| nrf52833dk_nrf52833 | Yes | 13| nrf52840dk_nrf52840 | Yes | 14| nrf5340dk_nrf5340 | Yes | 15| nrf9160dk_nrf9160 | Yes | 16 17## Overview 18 19Application initializes the nrfx_saadc driver and starts operating in the non-blocking mode. 20Program works as a simple state machine and starts in state @p m_current_state == STATE_SINGLE_CONFIG. 21In this state the following configurations apply: 22- STATE_SINGLE_CONFIG - SAADC driver is configured to work with only one channel ( @p m_single_channel ) in the blocking mode. 23 Afterward, @p m_current_state changes to STATE_SINGLE_SAMPLING. 24- STATE_SINGLE_SAMPLING - sampling on a single channel ( @p m_single_channel ) is performed specified number of times ( @p SAMPLING_ITERATIONS ), and then @p m_current_state changes to STATE_MULTIPLE_CONFIG. 25- STATE_MULTIPLE_CONFIG - SAADC driver is configured to work with multiple channels ( @p m_multiple_channels ) in the blocking mode. 26 Afterward, @p m_current_state changes to STATE_MULTIPLE_SAMPLING. 27- STATE_MULTIPLE_SAMPLING - sampling on multiple channels ( @p m_multiple_channels ) is performed specified number of times ( @p SAMPLING_ITERATIONS ). 28 29Before every sampling a calibration in the non-blocking manner is performed. 30Sampling is then invoked by the @p nrfx_saadc_mode_trigger() function. 31 32In the sample there are GPIOTE tasks configured to toggle specified ( @p m_out_pins ) loopback pins. 33Those tasks are triggered between successive samplings to verify the functionality of the SAADC on the nonconstant analog signal. 34 35> For more information, see **SAADC driver - nrfx documentation**. 36 37## Wiring 38 39To run the sample correctly, connect pins as follows: 40* `LOOPBACK_PIN_1A` with `LOOPBACK_PIN_1B`, 41* `LOOPBACK_PIN_2A` with `LOOPBACK_PIN_2B`, 42* `LOOPBACK_PIN_3A` with `LOOPBACK_PIN_3B`. 43 44## Building and running 45 46To run this sample, build it for the appropriate board and then flash it as per instructions in [Building and running](@ref building_and_running) section. 47 48## Sample output 49 50You should see the following output: 51 52``` 53- "Starting nrfx_saadc simple non-blocking example." 54- "Single channel SAADC test." 55- "SAADC event: CALIBRATEDONE" 56- "SAADC event: DONE" 57- "[Sample 0] value == ([0-9]{3})" 58- "SAADC event: CALIBRATEDONE" 59- "SAADC event: DONE" 60- "[Sample 0] value == -?[0-9]" 61- "SAADC event: CALIBRATEDONE" 62- "SAADC event: DONE" 63- "[Sample 0] value == ([0-9]{3})" 64- "SAADC event: CALIBRATEDONE" 65- "SAADC event: DONE" 66- "[Sample 0] value == -?[0-9]" 67- "SAADC event: CALIBRATEDONE" 68- "SAADC event: DONE" 69- "[Sample 0] value == ([0-9]{3})" 70- "SAADC event: CALIBRATEDONE" 71- "SAADC event: DONE" 72- "[Sample 0] value == -?[0-9]" 73- "SAADC event: CALIBRATEDONE" 74- "SAADC event: DONE" 75- "[Sample 0] value == ([0-9]{3})" 76- "SAADC event: CALIBRATEDONE" 77- "SAADC event: DONE" 78- "[Sample 0] value == -?[0-9]" 79- "Multiple channels SAADC test." 80- "SAADC event: CALIBRATEDONE" 81- "SAADC event: DONE" 82- "[Sample 0] value == ([0-9]{3})" 83- "[Sample 1] value == ([0-9]{3})" 84- "[Sample 2] value == ([0-9]{3})" 85- "SAADC event: CALIBRATEDONE" 86- "SAADC event: DONE" 87- "[Sample 0] value == -?[0-9]" 88- "[Sample 1] value == -?[0-9]" 89- "[Sample 2] value == -?[0-9]" 90- "SAADC event: CALIBRATEDONE" 91- "SAADC event: DONE" 92- "[Sample 0] value == ([0-9]{3})" 93- "[Sample 1] value == ([0-9]{3})" 94- "[Sample 2] value == ([0-9]{3})" 95- "SAADC event: CALIBRATEDONE" 96- "SAADC event: DONE" 97- "[Sample 0] value == -?[0-9]" 98- "[Sample 1] value == -?[0-9]" 99- "[Sample 2] value == -?[0-9]" 100- "SAADC event: CALIBRATEDONE" 101- "SAADC event: DONE" 102- "[Sample 0] value == ([0-9]{3})" 103- "[Sample 1] value == ([0-9]{3})" 104- "[Sample 2] value == ([0-9]{3})" 105- "SAADC event: CALIBRATEDONE" 106- "SAADC event: DONE" 107- "[Sample 0] value == -?[0-9]" 108- "[Sample 1] value == -?[0-9]" 109- "[Sample 2] value == -?[0-9]" 110- "SAADC event: CALIBRATEDONE" 111- "SAADC event: DONE" 112- "[Sample 0] value == ([0-9]{3})" 113- "[Sample 1] value == ([0-9]{3})" 114- "[Sample 2] value == ([0-9]{3})" 115- "SAADC event: CALIBRATEDONE" 116- "SAADC event: DONE" 117- "[Sample 0] value == -?[0-9]" 118- "[Sample 1] value == -?[0-9]" 119- "[Sample 2] value == -?[0-9]" 120``` 121 122[//]: # 123[Building and running]: <../../../README.md#building-and-running> 124