If I understand the UM correctly, using the FLASH peripheral flash can be read at a granularity of 16 bytes ("physical word"), and erased, written and programmed at a granularity of 512 bytes (1 page, 32 physical words). Also according to my understanding of the UM, writing proceeds by filling an peripheral-internal page register with 32 columns of physical words, and then calling the PROGRAM command on an erased page.
Is it possible to write in smaller units? My goal is to use a filesystem (ARM mbed's littlefs), and for this smaller writes would be great.
I have tried to following:
- erase page
- fill page register with zeros
- set specific page register column to a non-zero value
- fill page register with zeros again
- set different column to non-zero value
This "works" in the sense of no error or failure condition reported. However there are additional bits being set. As a specific example, on an LPC55S69 dev board, using the page starting 0x4_0200, I first write 0x1234567 (as physical word or 128 bit integer) to 0x4_0200, then 0x7654321 (again as physical word) to 0x4_0210 (second such word in the page). In this setup, I end up with the following data at the two addresses (note the spurious bits, bit 94 for the first location, bit 104 for the second location):
Is this expected behaviour? Is there any way to write smaller units to a previously "unwritten" part of a flash page?