3.1.2.2 DIAG_SRAM_Checkerboard()

diag_result_t DIAG_SRAM_Checkerboard (uint16_t startAddress, uint8_t length, uint16_t bufferAddress)

The Checkerboard RAM test writes the checkerboard patterns to a sequence of adjacent memory locations. This test is performed in units (memory chunks) of four bytes. This is a non-destructive memory test. This test performs the following major tasks:

  1. Saves the contents of the memory locations to be tested in the buffer defined by bufferAddress.

  2. Writes the binary value (length is dependent upon architecture) 101010... to the memory location, 'N', and the inverted binary value, 010101..., to the memory location, 'N+1', and so on, until the whole memory chunk is filled.

  3. Reads the contents of all the memory locations in the current chunk and verifies its contents. If the values match, the function continues; otherwise, it stops and returns an error.

  4. Step 2 and 3 are repeated by writing the inverted pattern to the same locations.

  5. Once a memory chunk is completed the test of the next chunk is started until all of the requested memory areas are tested.
    Parameters:
    in startAddress

    Address to an array declared in user memory for test

    in length

    Number of bytes to test

    in bufferAddress

    Address to location in memory where array will be stored during test

    Returns:

    DIAG_PASS - SRAM CF is not detected

    DIAG_FAIL - SRAM CF is detected

    DIAG_INVALID_ARG - When SRAM test addresses, test length, test region is invalid

    MISRA C:2012 Deviation Advisory: misra-c2012-15.5  

    Justification: The function should return as soon as a Fault is detected. Avoiding the use of multiple return statements would require having multiple additional checks which would add overhead, diminish code readability and would require defaulting the test result to DIAG_PASS. The latter is deemed less safe than only returning DIAG_PASS when all sections have been tested with no Fault detected. Since there is no functional termination code in this function, it cannot accidentally be omitted and since the function does not have any persistent side effects, there is no issue in discerning which side effects have been applied when the function is executed/exits and thus the deviation is deemed safe.