Hi Peter,
The testing whether D-Flash was already partitioned or not, could be implemented like here:
MMCCTL1_EEEIFRON = 1; //enable EEEIFR in memory map
if((*(unsigned int *far)0x120000 != DFPART) || (*(unsigned int *far)0x120004 != ERPART))
{
if((*(unsigned int *far)0x120000 == 0xFFFF) && (*(unsigned int *far)0x120004 == 0xFFFF))
err = DFLASH_Partition(DFPART,ERPART); //first startup of MCU - set the partition
else
{
//this should never happen
}
}
I would like to recommend also check whether D-Flash was portioned and formatted correctly. You may:
- Wait until Partition command ends and writes some flag into P-Flash/signalize and record in production.
- Or you may simply test address 0x107F00 during every reset.
The partition command may be interrupted by reset. Since DFPART, ERPART values are programmed prior D-Flash format, the unfinished Partition command may lead to the situation where EEE stops working after some time. Therefore I would like to recommend to test last sector header. For example:
MMCCTL1_EEEIFRON = 1; //enable EEEIFR in memory map
if((*(unsigned int *far)0x120000 != DFPART) || (*(unsigned int *far)0x120004 != ERPART))
{
if((*(unsigned int *far)0x120000 == 0xFFFF) && (*(unsigned int *far)0x120004 == 0xFFFF))
{
err = DFLASH_Partition(DFPART,ERPART); //first startup of MCU - set the partition
//Partitioning takes approximately 180ms
//you may signalize (write flag) here that D-Flash was formatted correctly
}
else
{
//this should never happen
}
}
else
{
if(*(unsigned int *far)0x107F00 == 0xFFFF) err = FORMAT_ERROR; //Was D-Flash correctly formatted?
//err signalize format error
//partitioning was interrupted
}
Note: The unfinished partition command may be fixed only by mass erase of the whole device in special single chip mode (simplest way presents Unsecure procedure execution) and by new Partitioning.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------