11.1.1 SRAM_DATA_REGION_LEN

#define SRAM_DATA_REGION_LEN (INTERNAL_SRAM_SIZE)

To decrease the size of the SRAM available for the application, in order to reduce worst case execution time (WCET) of the SRAM March diagnostic test, go to Project Properties -> XC8 Linker -> Option categories: Additional options and insert the following linker option in the additional linker options field:

-Wl,defsym=__DATA_REGION_LENGTH__="insert reduced SRAM size value"

Moreover, the start of the stack must additionally be configured to point at the new end address of the SRAM used by the application by using the following linker option (this will take effect after .init0 but before main()):

-Wl,defsym=__stack="insert new end address"

Finally, the SRAM_DATA_REGION_LEN macro must be set to the new reduced SRAM size value.

As an example, to reduce the SRAM size of an AVR128DA48 from default 0x4000 (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 should be set:

-Wl,defsym=__DATA_REGION_LENGTH__=0x2000 -Wl,defsym=__stack=0x5FFF

and the SRAM_DATA_REGION_LEN macro should be updated to:

SRAM_DATA_REGION_LEN 0x2000U