6.1.2.1 DIAG_SRAM_DATA_REGION_LEN

#define DIAG_SRAM_DATA_REGION_LEN (INTERNAL_SRAM_SIZE)

Handles a decrease of the size of the SRAM available to the application, to reduce the Worst-Case Execution Time (WCET) of DIAG_SRAM_MarchStartup() and/or DIAG_SRAM_MarchCMinus() in SRAM_MARCH_STARTUP mode and reduce the Fault Detection Time Interval (FDTI) of the aforementioned diagnostics in addition to DIAG_SRAM_MarchPeriodic().

To do this, go to: Project Properties>XC8 Linker>Option Categories: Additional Options Insert this in the Additional Linker Options field: -Wl,--defsym=__DATA_REGION_LENGTH__=<reduced SRAM size value>.

Configure the start of the stack to point to the new end address of the SRAM used by the application, by using the following linker option:  

-Wl,--defsym=__stack=<new end address>. This will take effect after .init0 but before entering the main() function.

Finally, set the DIAG_SRAM_DATA_REGION_LEN macro to the new reduced SRAM size value to comply with AoU-SRAM_MARCH_TEST-04 in Assumption of Use.

As an example, to reduce the SRAM size of an AVR128DA48 from the default, 0x4000, which is derived from the the INTERNAL_SRAM_SIZE macro value in the ioavr128da48.h to 0x2000, the new end address will be: INTERNAL_SRAM_START(= 0x4000) + 0x2000 - 1 = 0x5FFF. Thus, the following linker option must be set: -Wl,--defsym=__DATA_REGION_LENGTH__=0x2000 -Wl,--defsym=__stack=0x5FFF and the DIAG_SRAM_DATA_REGION_LEN macro must be updated to: DIAG_SRAM_DATA_REGION_LEN (0x2000U).