I am working on a project where I would like to use the flexNVM on a MK10DX128VLH7 as flex EEEPROM.
I am testing with the code below on a K20 Tower board, which has a PK20DX256VLL7, also with 32KB of flexNVM that can be used for EEEPROM. My steps are as follows:
------------------------------------------------------------
status_t ret = FLASH_Init(&flashConfig); // This returns kStatus_success
uint32_t currentEESize;
ret = FLASH_GetProperty(&flashConfig,kFLASH_PropertyEepromTotalSize, ¤tEESize); // Returns kStatus_success
uint32_t currentDflashSize;
ret = FLASH_GetProperty(&flashConfig, kFLASH_PropertyDflashTotalSize, ¤tDflashSize); // Returns kStatus_success
// Now, currentEESize==0 and currentDflashSize==32768, and I want to change that.
// First, I read SIM->FCFG1, which should tell me the total flexNVM size and EEPROM size.
uint32_t fcfg1 = SIM->FCFG1;
------------------------------------------------------------
Here, fcfg1 = 0xff03_0f00, which I decode as follows:
NVMSIZE = 0xF, which is not defined in the reference manual
PFSIZE = 0xF, which is not defined in the reference manual
EESIZE = 0x3, which is the code for 2KB (the desired size I want).
DEPART = 0xF, which the FlexNVM Partition code section says means Reserved (32KB data flash, no EEPROM)
Next, I attempt to program the partition:
------------------------------------------------------------
uint32_t eepromDataSizeCode = 0x3;
uint32_t flexnvmPartitionCode = 0x3;
ret = FLASH_ProgramPartition(&m_flashConfig, kFLASH_PartitionFlexramLoadOptionLoadedWithValidEepromData, eepromDataSizeCode, flexnvmPartitionCode);
------------------------------------------------------------
This returns error 103, which maps to kStatus_FLASH_AccessError
The following driver code is hit, in flash_command_sequence(&flashConfig); :
------------------------------------------------------------
/* checking access error */
if (registerValue & FTFx_FSTAT_ACCERR_MASK)
{
return kStatus_FLASH_AccessError;
}
------------------------------------------------------------
I don't know why this happens, and I have tried triggering a mass erase at this point, in code. When I reflash my firmware and debug, the same thing happens.
How do I get the flexNVM set up as EEEPROM? I'd love any input/sugggestions/sample code.
Thanks,
Collin
Solved! Go to Solution.
Thanks, line 56
if ( partition_flash( 0X33, 0X02) )//0X03
helped me see my error. The code below works.
------------------------------------------------------------
uint32_t eepromDataSizeCode = 0x33; // Set bits 5:4, bits 3:0 are eeesize code
uint32_t flexnvmPartitionCode = 0x03;
ret = FLASH_ProgramPartition(&m_flashConfig, kFLASH_PartitionFlexramLoadOptionLoadedWithValidEepromData, eepromDataSizeCode, flexnvmPartitionCode);
------------------------------------------------------------
Hi Collin Moore,
Please check my attached simple code, you can try that code, whether it works OK on your side or not?
If you still have question about it, please kindly let me know.
Have a great day,
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thanks, line 56
if ( partition_flash( 0X33, 0X02) )//0X03
helped me see my error. The code below works.
------------------------------------------------------------
uint32_t eepromDataSizeCode = 0x33; // Set bits 5:4, bits 3:0 are eeesize code
uint32_t flexnvmPartitionCode = 0x03;
ret = FLASH_ProgramPartition(&m_flashConfig, kFLASH_PartitionFlexramLoadOptionLoadedWithValidEepromData, eepromDataSizeCode, flexnvmPartitionCode);
------------------------------------------------------------