3.2.11 DIAG_FLASH

The DIAG_FLASH module is designed to verify the correct functionality of the Flash memories through a set of C function calls.

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

Table 3-12. 
FunctionDiagnostic MechanismUse CaseElapse Time (μs)~
DIAG_FLASH_Calibration()FLASH_CALIBRATIONPOST / OnDemand8.81
DIAG_FLASH_CRCCompare()FLASH_CRC_COMPAREPOST / OnDemand3260.35
DIAG_FLASH_CRCGenerate()NONEPOST/OnDemand3100.43
DIAG_FLASH_Functional()FLASH_FUNCTIONALPOST / OnDemand1158.20
DIAG_FLASH_Interrupts()FLASH_INTERRUPTSPOST24.66
DIAG_NVMCTRL_SFRReset()SFR_RESET_STATEPOST47.1458
DIAG_NVMCTRL_SFRWriteRead()SFR_WRITE_READPOST / OnDemand 32.04

Configuring the Diagnostic

DIAG_FLASH does not require additional configuration.

Run-time Pre-requisites

DIAG_NVMCTRL_SFRRead should be executed before DIAG_NVMCTRL_SFRWriteRead

Protection should be executed prior to all non-SFR functions

PAC_PeripheralProtectSetup(PAC_PERIPHERAL_NVMCTRL, PAC_PROTECTION_CLEAR); PAC_PeripheralProtectSetup(PAC_PERIPHERAL_DSU, PAC_PROTECTION_CLEAR);

DIAG_FLASH_CrcGenerate should be executed prior to any comparison functions

Using the Diagnostic

#include "definitions.h"

// Flash SFR Test
DIAG_TEST_STATUS DIAG_FLASH_SFRPost( void )
{
    DIAG_TEST_STATUS result;

    result = DIAG_NVMCTRL_SFRReset(NULL, 0, false);
    if (result == DIAG_TEST_PASSED)
    {
        result = DIAG_NVMCTRL_SFRWriteRead(NULL, 0, false);
    }
    return result;
}


// Flash Post testing
DIAG_TEST_STATUS DIAG_FLASH_Post( void )
{
    DIAG_TEST_STATUS result;
    
    // Check if all dependencies have been tested
    PAC_PeripheralProtectSetup(PAC_PERIPHERAL_NVMCTRL, PAC_PROTECTION_CLEAR);
    PAC_PeripheralProtectSetup(PAC_PERIPHERAL_DSU, PAC_PROTECTION_CLEAR);
    
    flash_crc = DIAG_FLASH_CrcGenerate(START_OF_FLASH, FLASH_SIZE);

    result = DIAG_FLASH_Functional();
    if (result == DIAG_TEST_PASSED)
    {
        result = DIAG_FLASH_Calibration();
        if (result == DIAG_TEST_PASSED )
        {
            result = DIAG_FLASH_CrcCompare(START_OF_FLASH, FLASH_SIZE, flash_crc);
            if (result == DIAG_TEST_PASSED )
            {
                result = DIAG_FLASH_Interrupts();
		    }
        }
    }
    return result;
}