It appears that when writing to the programming Flash of the K64F requires, the starting address must be "phrase"-aligned (64-bit alignment). See FTFL FTFE Flash controller behaviour
Are there any address alignment restrictions on read access?
Solved! Go to Solution.
Hi aberger,
If you do the read, just read the related address and get that address data.
Flash read operation don't need to use the flash module commander, so you can read it directly.
Wish it helps you!
If you still have questions about it, please kindly let me know.
Best Regards,
Kerry
Hi aberger,
If you do the read, just read the related address and get that address data.
Flash read operation don't need to use the flash module commander, so you can read it directly.
Wish it helps you!
If you still have questions about it, please kindly let me know.
Best Regards,
Kerry
I'm not sure what is being referenced here - I guess I'm limited in my understanding of the Flash capabilities of the K64 but I thought that all writes were to a full block (2k - 4k, depending on the device and Flash size) and not as small as 32/64 bits.
Now, the SDK Flash libraries allow for the writing of an arbitrary amount of data but they actually hide the fact that the full block is being erased and then written (with the data in addresses not being changed, buffered when the block is erased and then programmed back in with the new data).
There is also FlexRAM and FlexNVM (depending on your device) which gives you more flexibility in terms of write sizes. The referenced posts only discuss Flash, which is why I put in the Flash block write explanation.
Have I explained this correctly or is there something going on that I'm not aware of? I read/write Flash a lot in my applications, so understanding how smaller blocks of Flash could be written would be of value to me.
@myke_predko : you are correct that erasing a full sector (4kB) is necessary before a write occurs in that sector, but I don't believe that the subsequent write operation has to be sector-aligned.
For example, following an erase, you can safely perform write operations anywhere within that erased sector. The only requirement (assuming this is not a sector with FlexNVM) is that the write operation be phrase-aligned (64-bit alignment). (See K64 Sub-Family Reference Manual, 29.4.12.5 Program Phrase Command).
My question is simply whether read operations must also be phrase-aligned, or can individual bytes, words, and long-words be read out from flash?
I haven't found a way to perform "subsequent" writes on a sector.
I find that only one sector write is allowed after sector erase - you want to make a change, you have to erase and rewrite the sector.
If it's possible to do it without the erase, I'd be interested in understanding how, but I've never been able to do it.
myke
Sorry if I'm being unclear. As it states in the manual:
An erased bit reads '1' and a programmed bit reads '0'. The programming operation is unidirectional; it can only move bits from the '1' state (erased) to the '0' state (programmed). Only the erase operation restores bits from '0' to '1'; bits cannot be programmed from a '0' to a '1'
Say you proceed to program the first phrase of a given sector, (let's use the phrase between address 0x0008_0000 and 0x0008_0007 for concreteness). You are correct that you cannot reprogram that phrase to any arbitrary bit sequence without first erasing it (unless your are only changing '1's to '0s'). However, you can program any other phrase in the sector (e.g. 0x0008_0008 -- 0x0008_000F, and on up to 0x0008_0FFF) without erasing the whole sector first.
I understand exactly how Flash works, you didn't have to try and explain it to me.
I guess I wasn't clear; I have not been able to find a way to program (set bits to "0") any sub-sector of a Kinetis Flash sector after a program operation has taken place. I have worked at trying to figure out how to do it repeatedly and given up.
If you have a way of doing it, I'd love to see the code because that is something I would find useful.