I am in progress of switching from a K60 Tower to a K70 "homebueilt" PCB.
With the K70, I have problems writing to the internal flash.
The K60 is a K60FN 120MHz and the K70 is a K70FX 150MHz.
The first problem occured when I tried to run a "hello - world" - program (a bareboard project, gnerated by Codewarrior 10.2) in flash raher than in RAM.
It seemed to start normally (when I set the debugger to start at the program entry point rather than running to main() ).
But, unlike the K60, the program flash was not programmed and shows all FF's and therefore the program doesn't run.
This is a problem which others have reported as well, and so far no solution (any help welcome!).
Next, I tried to port my flash programming routines from the K60 (where they run flawlessly) to the K70, still executing out of RAM under the CW debugger.
I do not touch the upper parts of memory so I am sure I do not get in conflict with FlexNVM.
On both platforms, I start from a "bareboard project" and leave all clock settings etc. on factory defaults.
The only necessary change, so far, was to disable the watchdog.
My flash programming routines write directly to the FTFE registers.
I know that the flash region I am witing to must be cleared before I may program them. So part of my routine is an "erase sector" command, then I verify with the "read all 1s" - command and also check with the debugger's memory browser if all bytes read FF.
I am careful to close the debugger's memory browser before continuing, as this might cause a read collision error.
I use the "phrase programming".
I wait for the CCIF bit in the FSTAT register to show a 1 and clear any errors by writing 0x30 to the FSTAT register.
I write to the FCCOBx registers, and then I set FSTAT to 0x80.
In a loop I wait until the CCIF bit shows a 1 and check for errors.
When I single-step, the programming works.
When I let it run in a loop to program a number of bytes, let's say 128 bytes which means that I invoke phrase programming 16 times,
it usually works once or a few more times out of these 16 times.
After that, I see that the flash is not programmed, even though the FSTAT reads 0x80 again, i.e. completed and no errors.
Some earlier processor had a bug which let the CPU read a 1 in the CCIF bit even before programming started.
Could this happen with the K70?
Do I have an indication when I can continue programming, apart from the CCIF-bit?
As a workaround, I tried to add an additional loop which reads back the flash and compares it to the desired values, so I allow some time for the flash to get programmed. No success. Again, it may work when debugging and setting a breakpoint in that loop, but not when running "unatteded".
Any help is greatly welcome!