Hi Bernhard,
thanks again for you reply.
It really helps me to understand the matter.
But I'm a bit confused now.
Here's what I understand about reading/writing the flash in an LPC55xx:
- You can only erase a whole page (512 bytes aligned address and size)
- You can only write data to a whole page (512 bytes aligned address and size)
- You should only program a word once, unless you erase the page
- You can read on bytes
- You should not read from an erased page (due to ECC), unless some data has been programmed in the page
- Erased flash will return 0x00
- Programming means switching zero's to one's (at API level, FLASH_Read/FLASH_Write commands)
So writing '0xFFFF FFFF', as you suggested, will program all bits in the word, and you can't set it to zero's anymore.
Writing '0xF0F0 F0F0' afterwards will not change anything, I suppose.
But I think you suggest the other way around:
After an erase (flash is 0x0000 0000), you write 0x0000 0000 (nothing changes) and then write '0xF0F0 F0F0'.
And if I understand you correctly, this is not recommended, because you can only program it once?
But I would say that the first write ('0x0000 0000') does not program the word, and thus the word can be programmed with 0xF0F0 F0F0 without problem.
Else it wouldn't make sense to state that a word can only be programmed once, because then you have to write a whole page.
To clarify a bit, we have a usecase where we append data to the flash over time.
So we start with an erased flash page.
Then we want to append 0x0101 0101, so we write (512 bytes total) 0x0101 0101 0000 0000 0000 0000 0000 0000 etc.
Expected Flash content: 0x0101 0101 0000 0000 0000 0000 0000 0000 ...
Then we want to append 0x0110 1001, so we write (512 bytes total) 0x0000 0000 0110 1001 0000 0000 0000 0000 etc.
Expected Flash content: 0x0101 0101 0110 1001 0000 0000 0000 0000 ...
Then we want to append 0x0111 1000, so we write (512 bytes total) 0x0000 0000 0000 0000 0111 1000 0000 0000 etc.
Expected Flash content: 0x0101 0101 0110 1001 0111 1000 0000 0000 ...
(Note: I'm talking about the bitstate at API level here, not the actual state of the flash bits).
So each time the words that have been programmed before will be written again, but since we do it with all zero's I would say they are not programmed, and thus there is no problem.
Is that assumption correct?
If not, the internal flash is not useful for us, as you can only really write a page at a time.
Thanks, Jan Pieter