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:
| Function | Diagnostic Mechanism | Use Case | Elapsed Time (μs)~ |
|---|---|---|---|
| DIAG_DAC_Disable() | DAC_DISABLE | POST / OnDemand | 6 |
| DIAG_DAC_Enable() | DAC_ENABLE | POST / OnDemand | 6 |
| DIAG_DAC_Linearity() | DAC_LINEARITY | POST | 5 |
| DIAG_DAC_MaxSpeed() |
DAC_MAX_SPEED | POST | 7 |
| DIAG_DAC_SFRReset() | SFR_RESET | POST | 50 |
| DIAG_DAC_SFRWriteRead() | SFR_WRITE_READ | POST / 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;
}
