Hi kathirkamu annakamu,
Please take care the following points:
1. sector size difference
MK20DX128VLF5 sector size is 1Kbyte, MK22DX256VLF5 sector size is 2 KB.
Did you define the correct sector size.
2. Before write, did you do the according address erase?
If the according flash address already have data, and you didn't erase it before you write it, the flash operation will failed.
3. Disable the interrupt.
Before the flash operation, you need to disable the global interrupt, after the flash operation is finished, you can enable the global interrupt again.
4. The launch command code should put in the RAM.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------