Mark,
programming more bits to '0' should be clarified a bit, at least for newbies.
Programming erased long word (0xFFFFFFFF) to 0x5555FFFF programs some bits from erased state '1' to programmed state '0'. That's obvious, I guess.
But it is not completely true that programming 0x5555FFFF to 0x55555555 only programs additional bits to '0'. In fact it programs some bits from '1' to '0' and also overprogramms some previously programmed bits from '0' to '0'. Overprogramming is very very bad, (I believe) not allowed by Freescale and may lead to premature flash wearout.
When one wants to reprogram 0x5555FFFF to 0x55555555, he should write to the flash array 0xFFFF5555. Then resulting word in flash will be 0x55555555 and no bit will be overprogrammed.
Logics should be like this:
1) if ( (want_word & current_flash_word) != want_word ) {
flash must be erased. It is not possible to program want_word without erasing current_flash_word
}
2) // make want_word not overprogramming '0' bits to '0'. Force already programmed bits to '1'.
want_word = ~current_flash_word | want_word;
current_flash_word = 0x5555FFFF
~current_flash_word = 0xAAAA0000
want_word | ~current_flash_word = 0x55555555 | 0xAAAA0000 = 0xFFFF5555
3) latch want_word to flash and program it