3.1.3.1 DIAG_SRAM_Checkerboard()

diag_result_t DIAG_SRAM_Checkerboard (register uint8_t * startAddress, register volatile uint16_t length)

Performs the checkerboard algorithm nondestructively on the specified memory under test in smaller sections defined by the DIAG_SRAM_CHECKERBOARD_SEC_SIZE macro.

The device-specific memory space of the SRAM on each device is defined by the start address macro INTERNAL_SRAM_START and end address macro INTERNAL_SRAM_END, with a size defined in the INTERNAL_SRAM_SIZE macro. To make the test nondestructive and allow for both periodic testing with application data in SRAM and testing on start-up, the memory under test is divided into sections of a configurable size defined by DIAG_SRAM_CHECKERBOARD_SEC_SIZE. For each section tested, the current content of the section is first copied to a buffer (backupBuffer) before the checkerboard algorithm is run on the section. If no error is detected, the original content of the section is restored. If an error is detected while reading the checkerboard pattern in SRAM, the test algorithm is aborted and the data of the non-faulty addresses in the current section under test are restored to their original values. An additional check is performed to verify that the data is copied correctly both to and from the buffer. The first memory section, starting at the INTERNAL_SRAM_START address, is reserved for the buffer and has a length determined by DIAG_SRAM_CHECKERBOARD_SEC_SIZE. The address space of the buffer itself can be safely included in the test, where its content is not backed up unless the start address of the test is inside the buffer, resulting in a section under test that partially includes the buffer and the following SRAM data. In this scenario, the data outside the buffer address space is copied to the part of the buffer not under test. Finally, if the size of the memory under test is not a multiple of DIAG_SRAM_CHECKERBOARD_SEC_SIZE, the test is performed on the remainder as a separate section in the end.

The Checkerboard algorithm is executed with the four steps below:
  • Step 1: Write checkerboard pattern with up addressing order  

  • Step 2: Read checkerboard pattern with up addressing order  

  • Step 3: Write inverse checkerboard pattern with up addressing order  

  • Step 4: Read inverse checkerboard pattern with up addressing order

Note:

Global interrupts are automatically disabled when testing a section, and restored to the original state between testing sections to allow the application to service interrupts. The value DIAG_SRAM_CHECKERBOARD_SEC_SIZE will thus influence the length of time that global interrupts are disabled when running this diagnostic.

The diagnostic function reserves a buffer at the start of SRAM for doing backup of an SRAM section. For this reason, it is required to add a linker option to move the BSS section to avoid data collision during compilation. The required linker option is printed as pragma messages during compile time if DIAG_LINKER_OPTION_MSG_ENABLE is not zero.

Parameters:
in startAddress

The start address of the memory under test

in length

Defines the size of the memory under test