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