MK20 EEPROM failed to write

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

MK20 EEPROM failed to write

688 Views
tonyw
Contributor I

Hello,

I am using the MK20DX256VLL10, bare metal with KDS 3.2. I am using the FLASH_LDD from PEx. The EEPROM size is set to 4096 byte. The partition code is 0x4 and the EEPROM size code is 0x22. I am using the following code to configure the partition at the beginning. it seems working.

   Cpu_SetFlexNVMPartition();
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

....

  if(Cpu_GetFlexNVMPartitionCode() == FLEX_NVM_REQUESTED_PARTITION_CODE){
      SendDataToComputer("Successfully set Partition.\r\n ");
  }else{
      SendDataToComputer("Failed set Partition.\r\n ");
  }

The write function was generated by PEx:

FLASH1_Write(bitFLASH1Ptr, buf, FLASH_EEPROM_LOCATION, 2048);

I can write the data into EEPROM once and ONLY ONCE after "Mass erase on connect" is enabled and download the code into target board.

After that even I used the same code, the write function will be returned with FAIL code.

What do I need to do in order to successfully write data to it?

Tony W

0 Kudos
4 Replies

537 Views
tonyw
Contributor I

Kerry,

Thank you for the answer.

I am not able to find the code you have attached.

How can I find the code you have attached?

Tony W

0 Kudos

537 Views
tonyw
Contributor I

Kerry,

After I logged into my email and follow the link and backed to here again, I can see the attachment, thank you.

Tony W

0 Kudos

537 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Tony W,

   Yes, the attachment only can be seen after you log in.

   Please check my code on your side, it is very simple and useful.

    Any question about it, just let me know!

Wish it helps you!


Have a great day,
Kerry

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

0 Kudos

537 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Tony W,

    The partition code just can be do once after mass erased, after the partition is finished, the next power on, you won't do the partition again.

    Besides, Please don't enable the interrupt when you do the flash operation.

    I attached a bare mental code for the eeprom operation, you can refer to it, please modify the eeprom_size and dflash_size to the data whch you need.

   Then add the bare mental function directly to your project, and test it again.

   If you still have question, just let me know!

Have a great day,
Kerry

 

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

0 Kudos