nrfx 4.5.0
Loading...
Searching...
No Matches
SAADC maxmimum performance

SAADC maxmimum performance

The sample demonstrates an advanced functionality of the nrfx_saadc driver operating at its peak performance.

Requirements

The sample supports the following development kits:

Board Support
nrf52dk_nrf52832 No
nrf52833dk_nrf52833 Yes
nrf52840dk_nrf52840 Yes
nrf5340dk_nrf5340 No
nrf54l15dk_nrf54l15 Yes
nrf9160dk_nrf9160 Yes

Overview

Application initializes the nrfx_saadc driver and starts operating in the non-blocking mode. Sampling is performed at the highest supported frequency. In the sample m_single_channel is configured, and the SAADC driver is set to the advanced mode. To achieve the maximum performance, do the following:

  • Provide an external timer in order to perform sampling at MAX_SAADC_SAMPLE_FREQUENCY. You can do this by setting up endpoints of the channel m_gppi_channels [ gppi_channels_purpose_t::SAADC_SAMPLING ] to trigger the SAADC sample task ( nrf_saadc_task_t::NRF_SAADC_TASK_SAMPLE ) on the TIMER COMPARE event.
  • Provide hardware start-on-end. You can do this by setting up endpoints of the channel m_gppi_channels [ gppi_channels_purpose_t::SAADC_START_ON_END ] to trigger SAADC task start ( nrf_saadc_task_t::NRF_SAADC_TASK_START ) on the SAADC event end ( nrf_saadc_event_t::NRF_SAADC_EVENT_END ).

nrfx_saadc_offset_calibrate triggers calibration in a non-blocking manner. Then, sampling is initiated at NRFX_SAADC_EVT_CALIBRATEDONE event in saadc_handler() by calling nrfx_saadc_mode_trigger() function. Consecutive sample tasks are triggered by the external timer at the sample rate specified in SAADC_SAMPLE_FREQUENCY symbol.

In the example there is GPPI channel configured to test the functionality of SAADC. The endpoints are setup up in a way that connects the NRF_SAADC_EVENT_RESULTDONE event with the GPIOTE task toggling the OUT_GPIO_PIN pin.

‍For more information, see SAADC driver - nrfx documentation.

Wiring

To run the sample correctly, connect pins as follows:

  • LOOPBACK_PIN_1A with LOOPBACK_PIN_1B.

Building and running

To run this sample, build it for the appropriate board and then flash it as per instructions in Building and running section.

Sample output

You should see the following output:

- "Starting nrfx_saadc maximum performance example."
- "SAADC event: CALIBRATEDONE"
- "SAADC event: READY"
- "SAADC event: BUF_REQ"
- "SAADC event: DONE"
- "Sample buffer address == 0x([0-9a-z]{8})"
- ".Sample 0. value == -?[0-9]"
- ".Sample 1. value == ([0-9]{4})"
- "SAADC event: BUF_REQ"
- "SAADC event: DONE"
- "Sample buffer address == 0x([0-9a-z]{8})"
- ".Sample 0. value == -?[0-9]"
- ".Sample 1. value == ([0-9]{4})"
- "SAADC event: BUF_REQ"
- "SAADC event: DONE"
- ".Sample 0. value == -?[0-9]"
- ".Sample 1. value == ([0-9]{4})"