I'm using a MK10FN1M0VLQ12.
I must modify an old function from a previous project that writes to MCU flash (not the same MCU).
I have a lot of access to register PFB0CR in my old code.
But this register is doubled in MK10FN1M0VLQ12, called PFB01CR and PFB23CR.
I don't understand which one I should use. I must write to a region at address 0xFF000 to 0xFFFFF. What memory bank is this?
The reference manual says:
• For devices with program flash only: 4 blocks of program flash consisting of 4 KB
sectors
and
• FMC_PFB01CR controls the lower code addresses (blocks 0-1)
• FMC_PFB23CR controls the upper code addresses (blocks 2-3)
So is the flash memory (1MByte) divided in four parts so
block 0 = 0x00000000 - 0x001FFFFF
block 1 = 0x00200000 - 0x003FFFFF
block 2 = 0x00400000 - 0x005FFFFF
block 3 = 0x00600000 - 0x007FFFFF
And if this is correct I should use PFB23CR?
And one more question. Do I still need to invalidate the cache ways?
FMC->PFB01CR = PFB0CR_restore | FMC_PFB01CR_CINV_WAY(15);
Hello markosiponen:
We are sorry for the time with no response.
Your understanding is basically correct, but the addresses are wrong. They should be like this:
Block 0: 0x00000000 - 0x0003FFFF
Block 1: 0x00040000 - 0x0007FFFF
Block 2: 0x00080000 - 0x000BFFFF
Block 3: 0x000C0000 - 0x000FFFFF
So for the addresses 0xFF000 to 0xFFFFF you are correct to use PFB23CR.
And yes, it is recommended to invalidate the cache when reading/writing to flash.
Hope this helps clarifying.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------