Erasing and writing to the MC9S12XS128 D-Flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Erasing and writing to the MC9S12XS128 D-Flash

1,365 Views
aceshigh
Contributor I

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.

Labels (1)
0 Kudos
1 Reply

353 Views
Lundin
Senior Contributor IV
Yes you understand it correctly - it is very inefficient. This is a major weakness with most new Freescale MCUs. They used to come with EEPROM (or emulated EEPROM) that only needed a few cells erased, but for reasons unknown Freescale stopped using it. The new "data flash" in the latest S12X seems to solve nothing of this, it is roughly the same crap still.

The solution is to use the old S12D family (without X), the new S08D family or to look at the competition.

0 Kudos