I am using Kinetis K66 which has flash of 2MB. I am not able to perform write on flash region

cancel
Showing results for 
Search instead for 
Did you mean: 

I am using Kinetis K66 which has flash of 2MB. I am not able to perform write on flash region

469 Views
kuldeepmarker
Contributor I

I have written the flash driver for Kinetis K60 which is working fine, but when I tried to use the same driver for K66 board with some modification for flash I am not able to write the flash. I am not able to perform any operation on it. It looks like the FTFE module is not behaving as expected. I have check all the FTFE registers and the flash is not in secure state, so can anyone suggest me why I am not able to write to Flash or can I get a small snippet code for K66 flash initialization.

Tags (2)
0 Kudos
5 Replies

230 Views
mjbcswitzerland
Specialist V

Hi

If you were using a non-FPU K60 before you were using the long word write command for programming. The K66 (and processors with FPU in general) use phrase programming instead.

Check the valid Flash command set for the part being used or reference the uTasker project which has a flash driver that works on all possible Kinetis parts - flash code attached as reference. If you use the project in visual Studio you can emulate the internal Flash operations too for learning and testing complete project code usage.

Regards

Mark

0 Kudos

230 Views
kuldeepmarker
Contributor I

Hi Mark,

Thanks for your reply. I tried to look at the header file you provided but I have still some confusion about the phrase word mechanism you mentioned. I want to make use of program section command for writing big chunk of data to flash , so program section command has a different way of operating then the phrase command. I tried to find utasker project where internal flash writing is used so if possible can you provide me a sample code which makes use of internal flash read and write or at least  some pseudo code.

The point here I want to make is that I don't see any status change for FSTAT register when I perform any of the write operations, if my write is getting failed the FSTAT register should have reported me an error as I got when I was working on K60 board.

0 Kudos

231 Views
mjbcswitzerland
Specialist V

Hi

Section programming is supported in the area conditional on USE_SECTION_PROGRAMMING.

Programming can be tested by calling

extern int fnWriteBytesFlash(unsigned char *ucDestination, unsigned char *ucData, MAX_FILE_LENGTH Length);

ucDestination is a pointer to the flash location to be programmed (the first).
ucData is a pointer to a buffer containing the content to be programmed.
Length is the amount of data to be programmed.

If USE_SECTION_PROGRAMMING is enabled it will use sector programming (slightly quicker for blocks) as long as there are more than 2 long words to program (otherwise there is no advantage of section programming) and the destination is correctly aligned.

Regards

Mark

0 Kudos

231 Views
kuldeepmarker
Contributor I

Hi Mark,

My implementation is almost similar to what you have shared with me but still I am not able to write to flash region. I think there is some configuration issue related to flash that I am missing. So could there be some clock configuration that I am missing or any other relevant configuration related to FTFE module that I should take care of.

0 Kudos

231 Views
kuldeepmarker
Contributor I

Hi Mark,

I was able to successfully write on flash, I made the change in flash routine which needs to be executed in RAM and it worked for me. I don't know why the same code ran successfully on K60 board but gave problem on K66 board. Anyways I am able to perform write operation on flash that's a good news for me.

0 Kudos