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

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

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

936 Views
ryannickel
Contributor I

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):

pastedImage_0.png

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.

0 Kudos
1 Reply

363 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have checked a demo application for MK40DX256VLQ10 derivative and it works fine. According to your decription, it seems that the reset can be caused by a stack overflow. You can try increase stack size because the CPU_StartCmdAndWaitForCmdDoneOnTheStack function use the stack to execute a subroutine (the demo application has Stack size set to 0x400). You can set the stack size in the Component Inspector of the CPU, Build options tab, Generated linker file/Stack size property.

I have attached the demo application.

Best Regards,

Marek Neuzil

0 Kudos