AnsweredAssumed Answered

K60 FlexNVM Set Partition

Question asked by Kwon YM on Aug 22, 2014
Latest reply on Aug 4, 2015 by Kerry Zhou

I use MK60FX512VLQ15

I want to set partition that data 448K, eeprom 8K.

So, I did cording like it.But it has error.

How can I solve this problem?

 

Ah. EEPROM start at 0x14000000 right?

When I read or write data into EEPROM range, mcu is freesing.

 

main()

{

     ...

      InitFlexMem ();

     ...

}

 

void InitFlexMem (void)

{

    //FTFE_erase_all_block(); DFLASH_SIZE_448   0x04,  #define EEPROM_8K_8K  0x30

    EEP_init = DEFlashPartition(EEPROM_8K_8K,DFLASH_SIZE_448);   // EEPROM Data size : 16Kbyte , Data Flash size : 448Kbyte , EEP_init=0 :already partition,EEP_init=1 :no partition

}

 

 

 

 

byte DEFlashPartition(byte EEPDataSizeCode,byte DEPartitionCode)

{

    byte alreadypartition;

   

    if ((SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00)

    {

        alreadypartition=0;

        printf("\nDevice is already partitioned.\n");

    }

    else

    {

        FTFE_FCCOB0 = PROGRAM_PARTITION;

        FTFE_FCCOB1 = 0x00;

        FTFE_FCCOB2 = 0x00;

        FTFE_FCCOB3 = 0x00;

       

        // FCCOB4 is written with the code for the subsystem sizes (eeprom_size define)

        FTFE_FCCOB4 = EEPDataSizeCode;     //EEPROM 2K : 2K = 4Kbyte

       

        // FFCOB5 is written with the code for the Dflash size (dflash_size define)

        FTFE_FCCOB5 = DEPartitionCode;     //Data flash Size : 448K, EEPROM-backup Size :64K

       

       

        // All required FCCOBx registers are written, so launch the command

       FTFE_FSTAT = FTFE_FSTAT_CCIF_MASK; //->this line is occured ACCERR

       

        // Wait for the command to complete

        while(!(FTFE_FSTAT & FTFE_FSTAT_CCIF_MASK));

   

        //FTFE_FSTAT = 0xFF;

        alreadypartition=1;

    }

   

    // 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));

 

 

    //FTFE_FSTAT = 0xFF;

   

    return alreadypartition;

}

Outcomes