I'm porting a bootloader to my MK10DN512VLL10. I have used it in an MKL15Z128VFT4 before wihout problems.
When I execute a "Program Longword" and then read back the four written bytes I get a miss match. But if i single step my code it works.
If I disable the verification I can successfully download my application to flash with my bootloader.
I suspect the cache memory is the problem and it reads back the four bytes from cache memory and not from flash?
How do I make sure i really read back the four bytes from flash and not cache?
I found this Flash cache invalidate.
So i tested to disable the cache before and after write to flash and it works.
PFB0CR_restore = FMC->PFB0CR;
FMC->PFB0CR = PFB0CR_restore | FMC_PFB0CR_CINV_WAY(15); <--- I selected all as I don't know what else to select
FMC->PFB0CR = PFB0CR_restore;