Eeprom emulation ,why it takes so much time to run the code?

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

Eeprom emulation ,why it takes so much time to run the code?

Jump to solution
478 Views
ChenBowen
Contributor II

Dear engineer:

    I am using MPC5744P,  I try to build a eeprom emulation test project according to the driver  NXP provided.  I am not using SDK.  Luckily, my code works,but run really slowly.  It takes about several minutes to reach the  infinite "for loop" in main function. In the project, just initialize,write and read someting from eeprom,but takes several minutes .

 

 

this is my main function below:

/*****************************************************************
Main function
******************************************************************/
int main(void){

xcptn_xmpl();


system200mhz();


UINT32 i; /* index vairable */
UINT32 ret; /* store return code */
UINT32 pflash_pfcr1, pflash_pfcr2;
UINT16 id; /* id of data record */
UINT16 size; /* size fo data record */
BOOL stop_flag = FALSE; /* controll when to stop writing records*/
BOOL re_init_flag = FALSE; /* controll if it needs to re-init eeprom system*/


/* Unlock all eeprom blocks */
UNLOCK_EBLOCKS
/* Init all globle variable. If startup code can initialize all variables with
the thier values specified at declaration, user can skip calling this function */
InitGlobalVars();
/* Disable Data cache if present */
#if DCACHE_AVAILABLE
dcache_disable();
#endif
/* Invalidate flash controller cache */
DisableFlashControllerCache(&pflash_pfcr1,&pflash_pfcr2);

/* Init eeprom cache */
for(i = 0; i < EE_CACHE_SIZE; i = i+4)
{
WRITE32(cTable.startAddress + i, 0xFFFFFFFF);
}
/* Erase all eeprom blocks*/
ret = FSL_RemoveEeprom(&eepromConf,&CallBack);
if(ret != EE_OK)
{
ErrorTrap(ret);
}
/*---------------------------------------------------------------------*/
/* Init eeprom, will try 5 times if failed */
/*---------------------------------------------------------------------*/
i = 0;
ret = !EE_OK;
while ((i <5) && (ret != EE_OK))
{
ret = FSL_InitEeprom(&eepromConf,&CallBack);
i++;
}
if(ret != EE_OK)
{
ErrorTrap(ret);
}
swap_num = 0;
/*---------------------------------------------------------------------*/
/* Write eeprom data records */
/*---------------------------------------------------------------------*/
id = 4;

#if (SIZE_FIELD == 0)
size = DATA_SIZE; //size=0x40
#endif
while (stop_flag == FALSE)
{
#if (SIZE_FIELD >0)
size = id;
if(size > BUFFER_SIZE)
{
size = BUFFER_SIZE;
}
#endif
/* Init buffer*/
for (i = 0; i <size; i++)
{

WRITE8((UINT32)buffer + i, (UINT8)(i+size)); // buffer数组长度为20*4 ,size为0x40=64
}

ret = FSL_WriteEeprom(&eepromConf,id,size,(UINT32)buffer,&CallBack); // id前面定义为4
if(ret == EE_OK)
{
/* Call to FSL_MainFunction if there is a swap operation */
while(eraseStatus_Flag == ERASE_INPROGRESS)
{
stop_flag = TRUE;
ret = FSL_MainFunction(&eepromConf,&CallBack);
}
if (TRUE == stop_flag)
{

swap_num ++;
if (swap_num < 16 )
{
stop_flag = FALSE;
}
}
if(eraseStatus_Flag == ERASE_SWAPERROR)
{
re_init_flag = TRUE;
}
}
else
{
re_init_flag = TRUE;
}

if (re_init_flag == TRUE)
{
/* Call to FSL_InitEeeprom to try recovering eeprom system */
ret = FSL_InitEeprom(&eepromConf,&CallBack);
if(ret != EE_OK)
{
ErrorTrap(ret);
}
}
id = (++id)%0x50;
}
/*---------------------------------------------------------------------*/
/* Read data from eeprom */
/*---------------------------------------------------------------------*/
for(i = 0; i < BUFFER_SIZE/4; i++)
{
buffer[i] = 0xFFFFFFFF;
}
ret = FSL_ReadEeprom(&eepromConf,0x10,size,(UINT32)buffer,&CallBack);
if(ret != EE_OK)
{
ErrorTrap(ret);
}

/*---------------------------------------------------------------------*/
/* Delete data from eeprom */
/*---------------------------------------------------------------------*/
ret = FSL_DeleteRecord(&eepromConf,0x10,&CallBack);
if(ret != EE_OK)
{
ErrorTrap(ret);
}

for(i = 0; i < BUFFER_SIZE/4; i++)
{
buffer[i] = 0xFFFFFFFF;
}
ret = FSL_ReadEeprom(&eepromConf,0x10,size,(UINT32)buffer,&CallBack);
if(ret == EE_OK)
{
ErrorTrap(ret);
}
/*---------------------------------------------------------------------*/
/* Report eeprom status */
/*---------------------------------------------------------------------*/
ret = FSL_ReportEepromStatus(&eepromConf,&i);
if(ret != EE_OK)
{
ErrorTrap(ret);
}

/* Restore flash controller cache */
RestoreFlashControllerCache(pflash_pfcr1,pflash_pfcr2);
/* Enable Data cache if present */
#if DCACHE_AVAILABLE
dcache_enable();
#endif

for(;;) {
cnt++;

}
}

 

 

 

 

 

 

0 Kudos
1 Solution
468 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

original demo writes some data to flash until 16 swap operations are done:

lukaszadrapa_0-1672821430039.png

That's huge amount of data, this is not expected use case for real application. 

Take a look user manual, section 5 Appendix:

c:\Program Files (x86)\Freescale\EEE_Driver_v1.3.0\MPC5xxx\MPC5xxx_EED_UM.pdf

Here you can find expected initialization, read and write timings.

Regards,

Lukas

View solution in original post

0 Kudos
2 Replies
469 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

original demo writes some data to flash until 16 swap operations are done:

lukaszadrapa_0-1672821430039.png

That's huge amount of data, this is not expected use case for real application. 

Take a look user manual, section 5 Appendix:

c:\Program Files (x86)\Freescale\EEE_Driver_v1.3.0\MPC5xxx\MPC5xxx_EED_UM.pdf

Here you can find expected initialization, read and write timings.

Regards,

Lukas

0 Kudos
457 Views
ChenBowen
Contributor II

Thank you , I get it

0 Kudos