3.2.22 DIAG_RTC

The DIAG_RTC module is designed to verify the correct functionality of the Watchdog (RTC) through a set of C function calls.

Note: RTC routine will initialize the main clock to be 48 MHz. The user would need to call DIAG_OSCCTRL_Initialize to restore the clock.

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

Table 3-22. 
FunctionDiagnostic MechanismUse CaseElasped Timer (μs) ~
DIAG_RTC_Disable()RTC_DISABLEPOST / OnDemand28.25
DIAG_RTC_Enable()RTC_ENABLEPOST / OnDemand21.10
DIAG_RTC_Interrupts()RTC_INTERRUPTSPOST1081.75
DIAG_RTC_SFRReset()SFR_RESET_STATEPOST36.75
DIAG_RTC_SFRWriteRead()SFR_WRITE_READPOST / OnDemand 28.25
DIAG_RTC_TimerComparison()RTC_TIMER_COMPARISONPOST / OnDemand73.08
#define RTC_LOOP_MAX        100U

Configuring the Diagnostic

DIAG_RTC does not require additional configuration.

Run-time Pre-requisites

DIAG_RTC_SFRRead should be executed before DIAG_RTC_SFRWriteRead

Using the Diagnostic

#include "definitions.h"


DIAG_TEST_STATUS DIAG_RTC_SFRPost()
{
    DIAG_TEST_STATUS result[NO_OF_RTC_SFRPOST_TESTS]; 
    DIAG_TEST_STATUS test_status = DIAG_TEST_FAILED;
    int i;
    
    result[0] = DIAG_RTC_SFRReset(NULL,0,false);
    result[1] = DIAG_RTC_SFRWriteRead(NULL,0,false);
    
    // DO ADDITIONAL POST TESTS HERE
    for(i=0; i < NO_OF_RTC_SFRPOST_TESTS; i++)
    {
        if (result[i] != DIAG_TEST_PASSED)
        {
            test_status = result[i];
            break;
        }          
        else
        {
            test_status = DIAG_TEST_PASSED;
        }
    }
    return test_status;
}


DIAG_TEST_STATUS DIAG_RTC_Post()
{
    DIAG_TEST_STATUS result[NO_OF_RTC_POST_TESTS]; 
    DIAG_TEST_STATUS test_status = DIAG_TEST_FAILED;
    int i;
    
    result[0] = DIAG_RTC_Enable();
    result[1] = DIAG_RTC_Disable();     
    result[2] = DIAG_RTC_TimerComparison();
    result[3] = DIAG_RTC_Interrupts();
       
    // DO ADDITIONAL POST TESTS HERE
    for(i=0; i < NO_OF_RTC_POST_TESTS; i++)
    {
        if (result[i] != DIAG_TEST_PASSED)
        {
            test_status = result[i];
            break;
        }
        else
        {
            test_status = DIAG_TEST_PASSED;
        }
    }
    return test_status;
}