3.2.23 DIAG_SDADC
The DIAG_SDADC module is designed to verify the correct functionality of the Sigma-Delta Analog-to-Digital Converter (SDADC) through a set of C function calls.
Note: Only one pair of inputs are available on the:
ATSAMC21E18A-AUT-SL3. External hardware is required if the user executes
diagnostics.
The DIAG_SDADC software test API is mapped to the following safety mechanisms:
| Function | Diagnostic Mechanism | Use Case | Elasped Timer (μs) ~ |
|---|---|---|---|
| DIAG_SDADC_Boundary() | SDADC_BOUNDARY | POST / OnDemand | 499 |
| DIAG_SDADC_Disable() | SDADC_DISABLE | POST / OnDemand | 320 |
| DIAG_SDADC_Dma() | SDADC_DMA | POST | 255.47 |
| DIAG_SDADC_Enable() | SDADC_ENABLE | POST / OnDemand | 211 |
| DIAG_SDADC_Interrupts() |
SDADC_INTERRUPTS | POST | 988.89 |
| DIAG_SDADC_Linearity() | SDADC_LINEARITY | POST | 341.64 |
| DIAG_SDADC_Operation() | SDADC_OPERATION | POST | 118 |
| DIAG_SDADC_SFRReset() | SFR_RESET | POST | 84.11 |
| DIAG_SDADC_SFRWriteRead() | SFR_WRITE_READ | POST / OnDemand | 93.09 |
typedef enum {
DIAG_SADC_AIN0,
DIAG_SADC_AIN1,
DIAG_SADC_AIN2,
} DIAG_SADC_AIN;
Configuring the Diagnostic
DIAG_SDADC Safe-Plib must be configured as illustrated to supported to support all diagnostics:

Configuring the System

Pin Mapping

Run-time Pre-requisites
DIAG_SDADC_SFRReset should be executed before DIAG_SDADC_SFRWriteRead
Using the Diagnostic
#include "diag_definitions.h"
DIAG_TEST_STATUS DIAG_SDADC_SFRPost()
{
DIAG_TEST_STATUS result = DIAG_TEST_NOT_EXECUTED;
result = DIAG_SDADC_SFRReset(NULL,0,false);
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_SFRWriteRead(NULL,0,false);
}
return result;
}
DIAG_TEST_STATUS DIAG_SDADC_Post()
{
DIAG_TEST_STATUS result;
result = DIAG_SDADC_Enable();
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_Disable();
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_Linearity(DIAG_SADC_AIN1);
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_Boundary(DIAG_SADC_AIN1);
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_Interrupts(DIAG_SADC_AIN1);
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_Operation(DIAG_SADC_AIN1, DIAG_SADC_AIN2);
if (result == DIAG_TEST_PASSED)
{
result = DIAG_SDADC_Dma(DIAG_SADC_AIN1, DMAC_CHANNEL_1);
}
}
}
}
}
}
return result;
}
