Hi jcress,
What's the detail operation steps on your K60?
Please also let me know your detail K60 partnumber.
1. Do the mass erase
You even can use the JLINK commander: unlock kinetis
to finish the mass erase function.
2. Do the partition checking like this code
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");
return 0;
}
/* Write the FCCOB registers */
FTFL_FCCOB0 = FTFL_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
FTFL_FCCOB1 = 0x00;
FTFL_FCCOB2 = 0x00;
FTFL_FCCOB3 = 0x00;
/* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */
FTFL_FCCOB4 = eeprom_size;
/* FFCOB5 is written with the code for the Dflash size (dflash_size define) */
FTFL_FCCOB5 = dflash_size;
/* All required FCCOBx registers are written, so launch the command */
FTFL_FSTAT = FTFL_FSTAT_CCIF_MASK;
/* Wait for the command to complete */
while(!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK));
return 1;
}
Please note, you need to give the correct eeprom_size and dflash_size for K60 chip.
Main code can like this:
int main (void)
{
char ch;
uint32 temp=0;
#ifdef KEIL
start();
#endif
printf("\nRunning the hello_world project in K2050MHz family\n");
SCB_SHCSR|=SCB_SHCSR_BUSFAULTENA_MASK|SCB_SHCSR_MEMFAULTENA_MASK|SCB_SHCSR_USGFAULTENA_MASK;
printf("\nRunning FlexMem demo!!\n");
/* Partition the memory to enable FlexMem mode */
if ( partition_flash( 0X33, 0X03) )//0X03
{
/* Device has been partitioned for the first time, so this
* means the counters have not been initialized yet. We'll
* zero them out now.
*/
*((uint32 *)(LONGWORD_COUNTER_ADDR)) = 0x0;
/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
*((uint16 *)(WORD_COUNTER_ADDR)) = 0x0;
/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
*((uint8 *)(BYTE_COUNTER_ADDR)) = 0x0;
/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
}
//Write eeprom
*((uint32 *)(LONGWORD_COUNTER_ADDR)) = 0x0;
/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
*((uint16 *)(WORD_COUNTER_ADDR)) = 0x0;
/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
*((uint8 *)(BYTE_COUNTER_ADDR)) = 0x0;
/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
printf("\nlongword counter = 0x%08X", *(uint32 *)(LONGWORD_COUNTER_ADDR));
printf("\nword counter = 0x%04X", *(uint16 *)(WORD_COUNTER_ADDR));
printf("\nbyte counter = 0x%02X", *(uint8 *)(BYTE_COUNTER_ADDR));
////////////////////////
/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
temp = *((uint32 *)(LONGWORD_COUNTER_ADDR));
*((uint32 *)(LONGWORD_COUNTER_ADDR)) = (uint32) temp + 1;
/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
temp = *((uint16 *)(WORD_COUNTER_ADDR));
*((uint16 *)(WORD_COUNTER_ADDR)) = (uint16) temp + 1;
/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
temp = *((uint8 *)(BYTE_COUNTER_ADDR));
*((uint8 *)(BYTE_COUNTER_ADDR)) = (uint8) temp + 1;
/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
/* Display the initial counter values */
printf("\nlongword counter = 0x%08X", *(uint32 *)(LONGWORD_COUNTER_ADDR));
printf("\nword counter = 0x%04X", *(uint16 *)(WORD_COUNTER_ADDR));
printf("\nbyte counter = 0x%02X", *(uint8 *)(BYTE_COUNTER_ADDR));
printf("\nRunning FlexMem demo!!end\n");
while(1)
{
ch = getchar();
putchar(ch);
}
}
Although the code which I give you is the K20, but your K60 also can refer to it, just need to give the correct configuration.
Please try it again.
If you still have questions about it, please kindly let me know.
Best Regards,
Kerry