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:

Table 3-23. 
FunctionDiagnostic MechanismUse CaseElasped Timer (μs) ~
DIAG_SDADC_Boundary()SDADC_BOUNDARYPOST / OnDemand499
DIAG_SDADC_Disable()SDADC_DISABLEPOST / OnDemand320
DIAG_SDADC_Dma()SDADC_DMAPOST255.47
DIAG_SDADC_Enable()SDADC_ENABLEPOST / OnDemand211
DIAG_SDADC_Interrupts()

SDADC_INTERRUPTS

POST988.89
DIAG_SDADC_Linearity()SDADC_LINEARITYPOST341.64
DIAG_SDADC_Operation()SDADC_OPERATIONPOST118
DIAG_SDADC_SFRReset()SFR_RESETPOST84.11
DIAG_SDADC_SFRWriteRead()SFR_WRITE_READPOST / 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; 
}