I have a large array of uint16_t data to use as a lookup table, which is defined in flash. It's 4002 bytes in size, and I can set where in flash it is saved. I'm accessing it both as value = array[index]; and as pointer_to_array += index; value = *pointer_to_array; both with the same result.
The result is that if any element of the array is beyond 0x10000, reading it back results in 0xFFFF. Looking at it in 'Memory' in keil, it has the correct value; it's only when reading from it in code that it fails.
What could be causing this?
It can't be the keil code size limit, as that's 32k and the code size is just over 16k.
I've tried looking at the Memory Protection Unit, but as far as I can tell, readback protection applies to the whole of a flash region, not individual blocks. Could write/erase protection be affecting this somehow?
Can individual blocks of flash be powered on and off individually? So far I've only found this with RAM, but given 0x10000 is on the boundary of a flash block it seems plausible.
Or could something be preventing reading from higher than 16 bit flash addresses somehow?
Any help appreciated!