I'm Feng from China ,using MK10DX256VLL7 for a designing,I want to use the function of EEROM by settiing flexNVM and flexRAM.
First,We need partition before using EEROM, if the program runs on RAM, the partition command only be executed once, because ( SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00 before mass erase,thougn power off and then on.This is right.
But if the same program runs on FLASH,the patition command can be executed successfully,but if power off and then on, ( SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00 is false,that is ( SIM_FCFG1&SIM_FCFG1_DEPART(0xF)) == 0x00000F00 .so once power reset,the patition command will be executed once.however,at last,the program would be running on FLSH,I do not know how to resolve this question,can give me a suggestion ? thank you!
Code warrior 10.6.4 is my development environment.
The patition command as follow:
int partition_flash(int eeprom_size, int dflash_size)
/* Test to make sure the device is not already partitioned. If it
* is already partitioned, then return with no action performed.
if ((SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00)
printf("\nDevice is already partitioned.\n");
/* Write the FCCOB registers */
FTFE_FCCOB0 = FTFE_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
FTFE_FCCOB1 = 0x00;
FTFE_FCCOB2 = 0x00;
FTFE_FCCOB3 = 0x00;
/* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */
FTFE_FCCOB4 = eeprom_size;
/* FFCOB5 is written with the code for the Dflash size (dflash_size define) */
FTFE_FCCOB5 = dflash_size;
/* All required FCCOBx registers are written, so launch the command */
FTFE_FSTAT = FTFE_FSTAT_CCIF_MASK;
/* Wait for the command to complete */
while(!(FTFE_FSTAT & FTFE_FSTAT_CCIF_MASK));
IN a word , the patition command would be executed once power reset, because the SIM_FCFG1_DEPART of SIM register can not be saved when running on FLASH.