ACCERR while trying to partition EEPROM

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

ACCERR while trying to partition EEPROM

Jump to solution
1,586 Views
charles0000
Contributor III

I am trying to partition the EEE memory, but the result is always that the ACCERR flag in FTFL_FSTAT is set and the partitioning does not happen. I'm using FTFL_FCCOB0 = 0x80, FTFL_FCCOB4 = 0x35, FTFL_FCCOB5 = 0x05 and executing the command from RAM as instructed by various sources. The datasheet indicates that several conditions could cause ACCERR to be set. My best guess is that SIM_FCFG1 is reporting 0x39030f00, indicating that some part of the FlexNVM is already configured, but this is a new chip and I have executed the mass erase (FTFL_FCCOB0 = 0x44) several times, and SIM_FCFG1 still reports the same value. I was able to successfully partition one chip earlier in the development process, but I have tried multiple chips and cannot get any of them to partition correctly.


I don't know if this is related or not, but the microcontroller is also doing something else strange. Every time I power cycle it, the program disappears (I can tell by the outputs it is not running) and CodeWarrior tells me the chip has been secured and needs to be erased. When I debug my application, the debugger clearly shows it executing in the FLASH portion of memory (addresses 0x00000400 - 0x00040000) and not RAM.

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
1,225 Views
kerryzhou
NXP TechSupport
NXP TechSupport


Hi Charles Lehman,

    Your code is not correct, your partition command is wrong.

    Maybe you refer to the wrong reference manual of K20,  the reference manual of  MK20DX256VLK7 is K20P81M72SF2RM.PDF, the link is :

http://cache.freescale.com/files/32bit/doc/ref_manual/K20P81M72SF1RM.pdf?fasp=1&WT_TYPE=Reference Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation

9.jpg

8.jpg

You can't configure FTFL_FCCOB5 =0x05, because it is not the FlexNVM partition code for K20DX256VLK7.

You can use FTFL_FCCOB5=0X02 to configure data flash size to 16KB, and eeprom backup size to 16KB.

Please change the command, and do a masserase, then run from the RAM again.

If you still have question, please contact with me!
Best regards,

Jingjing

View solution in original post

0 Kudos
Reply
5 Replies
1,225 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Charles lehman,

      Thank you for your question in our community!

      Could you tell me the full name of your chip? And the eeprom size and the eeprom backup size which you want.

      I will help you to check whether your command is correct.

      From your SIM_FCFG1, your DEPART is 0xf, so your flexNVM is not partitationed OK,maybe your code is not correct.

    You can upload you project, I will help you to check it.

      Waiting for your reply!

Best regards,

    


Have a great day,
(Jingjing)

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,225 Views
charles0000
Contributor III

I am using MK20DX256VLK7. The code I am using to partition it, which I described in my original post, follows:

bool reinitEEPROM = FALSE;

// Partition memory if it has not yet been partitioned

//   (based on k40 flexmem example)

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

    reinitEEPROM = TRUE;

    FTFL_FCCOB0 = FTFL_FCCOB0_CCOBn(0x80); // Selects the PGMPART command

    FTFL_FCCOB1 = 0x00;

    FTFL_FCCOB2 = 0x00;

    FTFL_FCCOB3 = 0x00;

    FTFL_FCCOB4 = EEPROM_256_256;

    FTFL_FCCOB5 = DFLASH_SIZE_128;

    ExecuteFlashFromRAM();

}

// Wait for EEE memory to be ready

while ((FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK) == 0) ;

This references the following definitions:

#define __relocate_code__ __attribute__((section(".data"), long_call))

#define EEPROM_256_256 0x35   // subsystem A = 256 bytes, subsystem B = 256 bytes

#define DFLASH_SIZE_128   0x05

// Based on Freescale AN4695 and k40 flexmem example

void __relocate_code__ ExecuteFlashFromRAM(void)

{

    FTFL_FSTAT = FTFL_FSTAT_CCIF_MASK;

    while(!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK)) ;

}

I did try adjusting the FCCOB4 and FCCOB5 values without success.

0 Kudos
Reply
1,225 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Charles Lehman,

      I help you create a EPPROM project, this project the CW PE project.

      You can refer to my project, it is for MK20DX256VLK7,  and I test it works ok, please find the project from the attachment.

      My test result is as below:

Running FlexMem demo!!

longword counter = 0x00000000
word counter = 0x0000
byte counter = 0x00
LASTbyte counter = 0x00
longword counter = 0x00000001
word counter = 0x0001
byte counter = 0x01

You can see,  it can do write and read operation to eeprom, the operation address is defined as below:

#define LONGWORD_COUNTER_ADDR 0x14000040

#define WORD_COUNTER_ADDR 0x14000044

#define BYTE_COUNTER_ADDR 0x14000046

#define BYTE_LAST_ADDR 0x14000700

if already partition the eeprom, my code will display :Device is already partitioned.  then will not do partition operation.

BTW, my code is run in RAM.

Wish it helps you!

If you still have question, please contact with me.


Have a great day,
(Jingjing)

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,226 Views
kerryzhou
NXP TechSupport
NXP TechSupport


Hi Charles Lehman,

    Your code is not correct, your partition command is wrong.

    Maybe you refer to the wrong reference manual of K20,  the reference manual of  MK20DX256VLK7 is K20P81M72SF2RM.PDF, the link is :

http://cache.freescale.com/files/32bit/doc/ref_manual/K20P81M72SF1RM.pdf?fasp=1&WT_TYPE=Reference Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation

9.jpg

8.jpg

You can't configure FTFL_FCCOB5 =0x05, because it is not the FlexNVM partition code for K20DX256VLK7.

You can use FTFL_FCCOB5=0X02 to configure data flash size to 16KB, and eeprom backup size to 16KB.

Please change the command, and do a masserase, then run from the RAM again.

If you still have question, please contact with me!
Best regards,

Jingjing

0 Kudos
Reply
1,225 Views
charles0000
Contributor III

Thank you! I see what I was doing wrong now, the DEPART constants I was using were from the MK20DX256ZVMC10 datasheet, not MK20DX256VLK7. The tables for DEPART are completely different between those two chips.

0 Kudos
Reply