Hello Mateusz Paczynski:
Any flash memory location that you want to write must be in erased state (0xFF). Also for KL25 you can only write 4-bytes at a time to a longword aligned address in Flash. The minimum erase operation is of 1 flash sector, which in this case is 1 KB and again the sectors are aligned, e.g. the first sector is from address 0x0000_0000 to 0x0000_03FF.
For flash read/write/erase operations you can use the C90TFS driver, available in the same link:
http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe
There is an example for KL25 using this driver but it is for CodeWarrior:
EEPROM emulation on KL25 using C90TFS
Instead I recommend you to go with the latest tools. KSDK integrates the same C90TFS driver and there is an example for KL25 in this path once you install it:
C:\Freescale\KSDK_1.2.0\examples\frdmkl25z\demo_apps\flash_demo
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------