I'm trying to write my own routines to write to the program flash inside a K64FX512 and I can't seem to get it to work.
The commands that I pass to the FTFE unit seem to be succeeding: the CCIF bit gets set after some delay and there are no errors in the FSTAT register.
I used the 'section' attribute to place the functions that modify the flash into RAM to avoid Read While Write Violations. I can tell by looking at the size of the sections after building that this is actually placing the functions in RAM, although I have not been able to get the debugger to work inside of the RAM functions.
I'm attempting to write 16 bytes to Program Flash Address 0x00A000. I do an Erase Flash Sector operation(0x09), a Program Section operation (0x0B), and then read back the memory location using a pointer. But what I'm reading back is not what I wrote, and when I read back after an erase, I do not get 0xFF's, I get random data. So something is not right.
The code that I am using is attached.
Am I doing anything obviously wrong, or can anyone point me in the right direction?
Original Attachment has been moved to: FTFE_Example.c.zip