Derek Fritz

Erasing and writing to the MC9S12XS128 D-Flash

Discussion created by Derek Fritz on Aug 20, 2009
Latest reply on Aug 21, 2009 by Daniel Lundin

Quick question:

I'm setting up my data flash write routines for the MC9S12XS128 MCU.  From my understanding, any location in the data flash that is to be written to must first be in the erase state (0xFF) or an error occurs.

 

It appears that the absolute minimum amount of data flash that can be erased is a single sector (256 bytes) using the Erase D-Flash Sector command (0x12), while the maximum number of words that can be written to is 4 using the Program D-Flash command (0x11).

 

This seems inefficient, given that if I need to simply write to a single word-length parameter in my data flash, I need to first erase 256 bytes of flash at a minimum while making sure all the data I've just erased is saved, and then RE-WRITE all the data I just erased just to update one word.

 

Is my understanding of how the data flash works correct, or is there a more efficient way to erase/write (erase a single word perhaps?).

 

Thanks in advance.

Outcomes