3.2.6 DIAG_DAC

The DIAG_DAC module is designed to verify the correct functionality of the Digital to Analog Controller (DAC) through a set of C function calls.

The DIAG_DAC software test API is mapped to the following safety mechanisms:

Table 3-7. 
FunctionDiagnostic MechanismUse CaseElapsed Time (μs)~
DIAG_DAC_Disable()DAC_DISABLEPOST / OnDemand6
DIAG_DAC_Enable()DAC_ENABLEPOST / OnDemand6
DIAG_DAC_Linearity()DAC_LINEARITYPOST5
DIAG_DAC_MaxSpeed()

DAC_MAX_SPEED

POST7
DIAG_DAC_SFRReset()SFR_RESETPOST50
DIAG_DAC_SFRWriteRead()SFR_WRITE_READPOST / OnDemand 34

Configuring the Diagnostic

DAC Safe-Plib must be configured as illustrated to supported to support all diagnostics:

Run-time Pre-requisites

DIAG_DAC_SFRRead should be executed before DIAG_DAC_SFRWriteRead

DAC requires the ADC0 peripheral to be instantiated.

Using the Diagnostic

#include "diag_definitions.h"
 
// DAC SFR testing
DIAG_TEST_STATUS DIAG_DAC_SFRPost()
{
    DIAG_TEST_STATUS result;
    
    result = DIAG_DAC_SFRReset(NULL,0,false); 
    if (result == DIAG_TEST_PASSED)
    {
        result = DIAG_DAC_SFRWriteRead(NULL,0,false);
    }

    return result; 
}


// DAC Post testing                     
DIAG_TEST_STATUS DIAG_DAC_Post()
{   
    DIAG_TEST_STATUS result;
                      
    result = DIAG_DAC_Enable();
    
    if (result == DIAG_TEST_PASSED)
    {    
        result = DIAG_DAC_Disable();
    }
    
    if (result == DIAG_TEST_PASSED)
    {    
        result = DIAG_DAC_Linearity(DIAG_ADC0);
    }    
    
    if (result == DIAG_TEST_PASSED)
    {
        result = DIAG_DAC_MaxSpeed();
    }        
        
    return result; 
}