I have the following function:
static void ClearDisplay(void)
{
int X,Y;
GuiConst_INT16U *PixelPtr;
GuiConst_INT16U PIXEL_OFF = 65535;
PixelPtr = (GuiConst_INT16U*)sgl.CurLayerBufPtr;
for (Y = 0; Y < (GuiConst_INT16S)sgl.CurLayerHeight; Y++)
for (X = 0; X < (GuiConst_INT16S)sgl.CurLayerWidth; X++)
{
*PixelPtr = PIXEL_OFF;
PixelPtr++;
}
}
The following line causes a SIGTRAP interrupt when debugging, throwing a Guru Meditation Error with code LoadStoreError:
*PixelPtr = PIXEL_OFF;
After searching this up, I found the following:
This exception may happen in the following cases:
If the application has attempted to do an 8- or 16- bit read to, or write from, a memory region which only supports 32-bit reads/writes. For example, dereferencing a char* pointer to instruction memory (IRAM, IROM) will result in such an error.
If the application has attempted to write to a read-only memory region, such as IROM or DROM.
So I'm assuming the problem relates to the former since neither PixelPtr nor PIXEL_OFF are assigned const. I thought the problem would be cleared up if I set them both to the same datatype, GuiConst_INT16U (which is an unsigned short in the code), but the problem persists. What am I missing here?