.. include:: common.rst
3. Analyzing The Demonstration Example
This section analyzes an application example which demonstrates using the SDADC adapters. The example is based on the freertos_retarget sample code found in the SDK. It adds one additional freeRTOS task which is responsible for performing analog-to-digital measurements on the internal 1/4 Vbat. Both synchronous and asynchronous SDADC operations are demonstrated.
3.1. Application Structure
The key goal of this demonstration is for the device to perform a few SDADC operations in the task. Depending on the value of the USER_SDADC_SYNC_EN
macro, a synchronous or an asynchronous SDADC operation is selected.
If you want change to the external input source, SDADC_INPUT_VBAT
macro should be undefined in plateform_device.h
.
At the end of the measurement, the raw ADC value is converted into millivolt (mV) and a debugging message with the converted data is sent to the serial console.
Note
It is essential that developers must not call asynchronous related APIs without guaranteeing that the previous asynchronous transaction is finished. To ensure this, after triggering an asynchronous SDADC operation, the calling task blocks its execution until the arrival of a freeRTOS signal, indicating the end of the current SDADC operation.
Note
The tutorial starting a new project is recommended for getting start with a new project.

Figure 5 SDADC Conversions SW FSM - Main Execution Path