AnsweredAssumed Answered

Reset when calling SetFlexNVMPartition() using KDS, PE and K22

Question asked by Ryan Nickel on Dec 11, 2014
Latest reply on Feb 12, 2015 by Marek Neuzil

I am using Processor Expert within Kinetis Design Studio 1.1.1 with a MK22DX256VLH5 processor and I am trying to get the FlexNVM EEPROM to work but having difficulty with the partitioning.

 

I've setup the memory organization as per the attached screenshot (all EEPROM no DFlash):

 

 

It is my understanding that the partitioning must either be done by the programmer (I am using a PE Micro Multilink Universal FX) or within software.  I'm currently using the GDB server for programming / debugging within KDS and I don't see any options to specify the partition information so I have decided to go the software route (although I am not opposed to using the programmer to set the partition).

 

My partition initialization code (called from the main function) is as below:

 

#define FTFL_FCNFG_EEERDY    0x01

void FlexEE_Init()

{

 

    uint16_t code = Cpu_GetFlexNVMPartitionCode();

    if (code == FLEX_NVM_REQUESTED_PARTITION_CODE)

    {

          // output debug information

    }

    else

    {

        if (Cpu_SetFlexNVMPartition() == ERR_FAILED )

        {

               // output debug information

        }

 

        if (Cpu_SetFlexRAMFunction(FlexRAM_AS_EEPROM) == ERR_FAILED)

        {

               // output debug information

        }

    }

    int count = 0;

    while (!(FTFL_FCNFG & FTFL_FCNFG_EEERDY))

    {

        if (count++ > 20000)

        {

            // output debug information

            return;

        }

    }

}

 

The code returned from GetFlexNVMPartitionCode is always 0x3F0F which means the EEPROM Data Set Size and FlexNVM Partition Code registers are all set to 1.  This is fine because it means it needs to be partitioned.  When Cpu_SetFlexNVMPartition() is called it gets all the way until the point where within  Cpu_StartCmdAndWaitForCmdDoneOnTheStack() it goes to call the code on the stack and then the processor resets back to the initial startup points @ __thumb_startup(void).

 

Any help or insight would be appreciated.

Outcomes