Hello,
Am using K22FN1M0 device from Kinetics and getting a peculiar issue with flash write.
Am currently using PE component IntFlash to write into internal flash.
I have used byte write, word write and long write PE functions.
i am facing 2 issues
1) when i use long write and increment the address by 4 immediately program crashes on next write i.e. if start address is 0x6000 the program crashes at 0x6004. but if i increment address by 8 it works fine. Increment address by 8 always works.
2) I tried writing fixed data and using long write. when i write 0xAA55AA55 and increment the address by 4 it writes correctly and am able to write whole flash with 0xAA55AA55 data and increment address by 4. But when i write 0x45 data application crashes.
earlier I was using K22FN512 device with PE component and did not find any such issue.
The same problem comes for further sectors and erase sector returns success always.
please let me know what could be the issue.
Also if you have a sample code with K22FN1M0 internal flash write which works please share it with me.
Thanks
Regards,
Anuj
Hi Anuj Tanksali,
I highly recommend you to use our KSDK code for K22FN1M0, you can download it from this link:
https://mcuxpresso.nxp.com/en/builder
Select your chip, then generate the code and download it, you can find the flash code in folder:
SDK_2.3.1_MK22FN1M0Axxx12\boards\twrk21f120m\driver_examples\flash
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Kerry Zhou,
Thanks for your reply. I will use the sdk from the builder and check.
Does this SDK contain sample code for flash swap memory feature in K22FN1M0.
Regards,
Anuj
Hi Anuj
The uTasker project includes also a complete K22 swap block solution - see fnSwapMemory() in kinetis_FLASH.h - and it can be simulated in Visual Studio for analysis purposes.
Regards
Mark
Hi Anuj
The K22FN512 and K22FN1M are not fully compatible; one is an SF7 part and the other an SF5 part - with regards to Flash, the K22FN512 uses long word programming and the K22FN1M uses phrase programming. Phrases need to be written as 8 byte blocks and has different commands to do it.
If using PE it may not be supported for this chip (PE development was stopped some time ago and it may not support newer parts) or maybe you have chosen the part incorrectly (?)
In case of difficulties take a look at the uTasker project (open source on GitHub) since this has a flash driver that adapts itself to an device and allows Flash simulation in Visual Studio for faster professional developments - the FRDM-K22F and BLAZE_K22 targets are references for the two parts in question.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html
Flash interface:
http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF
Hello Mark,
Thanks for your reply. I was able to use set block flash function of PE component of internal flash and my code worked using 8 byte blocks.
But i have a question regarding other PE functions such as setbyte, setword, setlong. for these functions to work is there any limitiation on address boundary. it was observed that if these functions work if address to be written is on 8 byte boundary. e.g. 0x6000, 0x6008...
why is the use of these functions in PE component then. suppose i want to write word consecutively to addresses 0x6000, 0x6002, 0x6004...
or long consecutively to 0x6000, 0x6004m 0x6008... . these functions do not work in this case
but in case of K22FN512 we used set word 2 times to set 2 bytes 2 times and increase the address by 4. it works in K22FN512.
can you please explain why 8 byte block only will work on K22FN1M0. is there any specific reason to go for 8 byte block write such as size of flash on device?
Regards,
Anuj