FRAM reading outside boundaries

Calling the function with a starting address of 0x7FFC, it does the following:

write 0 to 0x7FFC, write 100 to 0x0000, read 0x7FFC ( 0), read 0x0000 (100)
write 1 to 0x7FFD, write 101 to 0x0001, read 0x7FFD (1), read 0x0001 (101)
write 2 to 0x7FFE, write 102 to 0x0002, read 0x7FFE (2), read 0x0002 (102)
write 3 to 0x7FFF, write 103 to 0x0003, read 0x7FFF (3), read 0x0003 (103)
write 4 to 0x8000, write 104 to 0x0004, read 0x8000 (4), read 0x0004 (104)

This is where it goes wrong. The write to 0x8000 is actually writing to location 0x0000, which overwrites the 100 that you wrote to 0x0000 earlier. When you read from 0x8000, it is actually reading from 0x0000, which now contains the 4 that you just wrote to it. The write to 0x0004 is totally irrelevant, and has no effect on address 0x8000 or 0x0000, and anything you wrote to 0x0000 before the write to 0x8000 also has no effect.

The NewTestEprom function works properly because the write to 0x8000, that actually places data into address 0x0000, is later overwritten by the explicit write to 0x0000. This results in the later read of 0x8000 returning the data from the write to 0x0000 instead of the data from the write to 0x8000.

1 Like