AnsweredAssumed Answered

K21 Flex Memory Setup

Question asked by al1 on Feb 19, 2015
Latest reply on Jul 9, 2015 by Jorge_Gonzalez

I reviewed couple of posts regarding setting flex memory on Kinetis devices and so far I am still facing issues with setting the Flex memory on the MK21FX512VLQ12.


First I am using the PE to set peripherals, using the Cpu_SetFlexNVMPartition() causes the core to lockup and reset (lockup bit in RCM_SRS1 is set) so I gave up on using this function.


I tried the following code:




        /* 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 = 0x18; //64bytes

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

          FTFE_FCCOB5 = 0x0B; //32KB for data and 96KB for EE Backup

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

          while (!(FTFE_FSTAT & FTFE_FSTAT_CCIF_MASK)){};


          FTFE_FSTAT = FTFE_FSTAT_CCIF_MASK;  // step in line by line after this line


          /* Wait for the command to complete */

          while(!(FTFE_FSTAT & FTFE_FSTAT_CCIF_MASK)){}; // this is the while loop where it resets


Using the debugger and going line by line starting at the command setting the CCIF bit in the FSTAT I was able to set the flex memory the way I wanted.

Now if the debugger was not stepping line by line at the last while loop the program will Lockup again and the core resets.


Anyone has any thoughts about this issue ?