MK22FN1M0A internal flash reading

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MK22FN1M0A internal flash reading

Jump to solution
538 Views
kent_gu
Contributor III

Hi,

I am using MK22FN1M0A, would like to use internal flash to store some calibration data to simulate EEPROM function. Have read the flash example, now question is?

#1, How to make the program don't use the special flash sector for EEPROM function? It means that how to arrange special sector for EEPROM fucntion? We can define it in KDS?

#2, How to call the data in virtual EEPROM(flash)? In the example, there are erase special sector function,, write special sector function, no how to read special sector? 

#3, How about the flash endurance? Don't have any idea about it. If don't erase and write virtual EEPROM(flash), just read it when power up the board, it will don't affect flash endurance. It means that there is just several times of configuration change, and then several time virtual EEPROM operation, the virtually EEPROM should work well?

Any input is appreciated!

Have a good day.

Kent

Tags (1)
0 Kudos
1 Solution
393 Views
kerryzhou
NXP TechSupport
NXP TechSupport

HI Kent,

Answer your 3 questions:
1.How to make the program don't use the special flash sector for EEPROM function in KDS?
 Normally, I would like to use the last sector in the flash to do as the special data store place.
 You chip is  MK22FN1M0AVLH12, the flash sector size is:4KB
 the last flash sector is from 0x000f_f000 to 0x000f_ffff
 You can modify the .ld file, two steps:
(1) add your own flash range in MEMORY{}
   m_data (RW) : ORIGIN = 0x000ff000, LENGTH = 0x00001000
(2) add the code in the SECTIONS{} area:

.mydata :
{
. = ALIGN(4);
KEEP(*(.mydata ))
. = ALIGN(4);
} > m_data

2, How to call the data in virtual EEPROM(flash)?
Read is very simple, you don't need to use the flash commander,just read the address directly is ok.
printf("0x%x,",*((uint32_t *)(0x000ff000))); // read 4bytes from address 0x000ff000
printf("0x%x,",*((uint16_t *)(0x000ff000)));//read 2 bytes from address 0x000ff000
printf("0x%x,",*((uint8_t *)(0x000ff000)));// read 1 byte from address 0x000ff000

3, How about the flash endurance?
You can find it from the datasheet. It is Cycling endurance, the typical data is 50K cycles, the min. data is 10K cycles.
Sector is the minimun size in the flash, the round of erase and write is one flash operation cycle.
Take an example, if your operation times(erase times) over 50K cycles, this sector flash may be broken, the endurance is over. Then the write or erase will be failure.
This is the typical character of flash, even EEPROM, it also have the endurance, so you should associate with your application, whether the this endrance is meet your write and erase demand.

Wish it helps you!
If you still have question, please let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
394 Views
kerryzhou
NXP TechSupport
NXP TechSupport

HI Kent,

Answer your 3 questions:
1.How to make the program don't use the special flash sector for EEPROM function in KDS?
 Normally, I would like to use the last sector in the flash to do as the special data store place.
 You chip is  MK22FN1M0AVLH12, the flash sector size is:4KB
 the last flash sector is from 0x000f_f000 to 0x000f_ffff
 You can modify the .ld file, two steps:
(1) add your own flash range in MEMORY{}
   m_data (RW) : ORIGIN = 0x000ff000, LENGTH = 0x00001000
(2) add the code in the SECTIONS{} area:

.mydata :
{
. = ALIGN(4);
KEEP(*(.mydata ))
. = ALIGN(4);
} > m_data

2, How to call the data in virtual EEPROM(flash)?
Read is very simple, you don't need to use the flash commander,just read the address directly is ok.
printf("0x%x,",*((uint32_t *)(0x000ff000))); // read 4bytes from address 0x000ff000
printf("0x%x,",*((uint16_t *)(0x000ff000)));//read 2 bytes from address 0x000ff000
printf("0x%x,",*((uint8_t *)(0x000ff000)));// read 1 byte from address 0x000ff000

3, How about the flash endurance?
You can find it from the datasheet. It is Cycling endurance, the typical data is 50K cycles, the min. data is 10K cycles.
Sector is the minimun size in the flash, the round of erase and write is one flash operation cycle.
Take an example, if your operation times(erase times) over 50K cycles, this sector flash may be broken, the endurance is over. Then the write or erase will be failure.
This is the typical character of flash, even EEPROM, it also have the endurance, so you should associate with your application, whether the this endrance is meet your write and erase demand.

Wish it helps you!
If you still have question, please let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos