Hi,
Let me explain:
The P-Flash at S12XE is written by phrases.
Phrase—An aligned group of four 16-bit words within the P-Flash memory. Each phrase includes eight ECC bits for single bit fault correction and double bit fault detection within the phrase.
So, if you write a phrase once, the ECC checksum for aligned 64bit is stored together with your data. When you write the same phrase again without sector (1024 bytes) erase, new ECC checksum is calculated and it rewrite already written value (only log1->log0 is possible during flash write). So, the ECC checksum is now damaged and you will probably able to detect single or double bit checksum error during the P-Flash read.
In your first case, the P-Flash detected single bit ECC checksum error and automatically repair the bit error (add one log1 at a most probable place). Therefore, you read different value than you write.
In your second case, the P-Flash didn’t detect ECC checksum or rather detected double bit ECC checksum error. Such an error cannot be fixed automatically. Therefore, you read data what you wrote into P-Flash.
You may check detected errors by DFDIF and SFDIF flags in FERSTAT register.
The cumulative write within a phrase is not allowed.
I hope it helps you
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------