Hi,
I am using an ATXmega128A1 with external SRAM (EBI). Right now I only use the direct addressable part of the SRAM from 0x4000 - 0xFFFF. I've got the impression that everything works fine.
But I have got a SRAM test function which you can see below:
bool ext_sram_test(void) { uint16_t *psram; uint16_t iii; uint16_t err; #define SRAM_ADDR 0x4000 #define SRAM_SIZE 0xC000 psram=(uint16_t *)SRAM_ADDR; // set pointer to begin of SRAM err=0; // error counter // write pattern inro SRAM for (iii=0; iii < SRAM_SIZE/2; iii++) { *(psram++)=iii; } psram=(uint16_t *)SRAM_ADDR; // set pointer to begin of SRAM for (iii=0; iii < SRAM_SIZE/2; iii++) // verify pattern { if (*(psram++)!=iii) { err++; } } if (err) { return false; } else { return true; } }
The first loop which writes the simple pattern into SRAM works fine. If I set a breakpoint behind it I can see the pattern in the memory window of my debugger. But stepping forward into the verify loop leads to the bug. Reading the data does not work. It seems like reading random data.
The funny thing is if I reduce the size definition of my SRAM by 2 bytes everything is fine:
#define SRAM_SIZE (0xC000-2)
The verify loop detects no errors anymore.
I wonder if this is a compiler bug. Can anyone help me?
Actually my workaround is to reduce the SRAM_SIZE. The SRAM test and also the usage of external SRAM in other parts of my software works fine.
I am using Atmel Studio 6.1.2730 SP2 with the suiting AVT-GCC compiler.