Hi Peter,
Several points -
1) I recommend always following Generic Flash Command Write Sequence Flow in the data book as a MUST else you can be violating the spec for the part.
2) I suspect that, apart from mybe not having set FCLKDIV and not checking CCIF == 1 (both of which are checked in the Generic Flash Command Write Sequence Flow), one of your problems is certainly coming from the '|=' in this line
FSTAT |= (PVIOL | ACCERR);
the OR-EQUALS is a read modify write operation which is a real hazzard on any registers containing 'write 1' to clear flags and an absolute MUST NOT DO especially on the FSTAT register. Here's what it does
a) reads the FSTAT register (CCIF will probably be 1, or at least it should be if you are trying to execute an FTM command (and you should be checking))
b) OR's (PVIOL|ACCERR) with it - NOTE you now have at least CCIF set in this intermediate result
c) writes the result back to FSTAT
and writing a 1 to the CCIF bit launches the FTM command !!!!!!!!!!
So you should use FSTAT = (PVIOL | ACCERR);
Same goes for FSTAT |= CCIF, probably won't cause any probelms in fact but better practice to just use FSTAT = CCIF.
3) FYI, the ENABLE_D_FLASH command was renamed to FULL_PARTITION_DFLASH some time ago - make sure you have the latest data book from the Freescale web.
4) Also, I would recommend leaving the MMCCTL1 register at it's default -no need to enable the IFR visibility at all.
5) Something else to watch out for if you are debugging programming the Flash in CodeWarrior and want to see the value change:
In your cable menu you'll find a option called Debugging Memory Map (or similar)
double click on global 00100000-0013FFFF global eeprom and make sure 'refresh memory when halting' is set (by default it isn't)
this will result in the D-Flash changes being updated in the memory window.
6) An EEE ApNote will be available on the web site shortly.
cheers,
dog