Hello,I meet a quetion about DFlash of MC9S12XET256,I use it by the follow steps:
Step1: I use the full patition d-flash commnd 0xf in case that with BDM, and set DFPART is 0x0,ERPART is 0x10;
Step2: I use Enable EEE commnd 0x13 and write to buffer ram,it's ok, after that I remove BDM(BKGD not connect);
step3: In the case that without BDM,I use Query cmd test the patition, and visible EEE IFR (MMCCTL1's Bit5 set),result is normal,use ok;
step4: after step3,I run my board for a short time, and one day I find i can not use the eeprom,i use the query cmd,
the result(use query )is DFPART is 0xFFFF,ERPART is 0xFFFF,I read the EEEIR and the result is 0x120004 is 0x00,
0x120005 is 0x00, 0x120006 is 0x10, 0x120007 is 0x10FF, i am sure during step4 without BDM.
My question are :
1:what can make the partition's parameters become zero in case that without bdm?
2:In case that no patition how can i repatition by no bdm?
thanks for reply my quetion!
Solved! Go to Solution.
Hi alex,
I could simply help you in case of partition command unexpected interrupt simulations.
I already created example code some time ago. Please look at attachment.
You could simply play with Start_interval() parameter and try simulate similar issue as in your case.
In root of project you could find examples of OK and NOK memory contents.
For recovery, please unsecure MCU and load code again, after that you could execute partition command once again.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
ERPART 0x10 is too big. Buffer RAM size is 2kB and ERPART specifies how much data you, up to 2kB, you are going to store in emulated EEPROM. Max ERPART figure is 2kB / 256 = 8. Perhaps wrong ERPART caused your problem.
It is not necessary to use BDM-only full partition command (0xF). Alternatively from normal mode you can 1) issue EEPROM query command (0x15) to determine if EEPROM is partitioned, and 2) in case 0x15 command returned 0xFFFF (in FCCOBIDX=2, FCCOB == 0xFFFF), issue normal mode partition command (0x20). And finally 3) Issue enable emulation command (0x13).
void SetupEeprom(void)
{
FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
FCCOBIX = 0;
FCCOB = 0x1500; // EEPROM QUERY
FSTAT &= FSTAT_CCIF_MASK;
while(!(FSTAT & FSTAT_CCIF_MASK))
{
}
FCCOBIX = 2;
if(FCCOB == 0xFFFF)
{
FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
FCCOBIX = 0;
FCCOB = 0x2000; //0x0F00; // partition
FCCOBIX++;
FCCOB = 0; //DFPART
FCCOBIX++;
FCCOB = 8; //ERPART
FSTAT &= FSTAT_CCIF_MASK;
while(!(FSTAT & FSTAT_CCIF_MASK))
{
}
}
FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
FCCOBIX = 0;
FCCOB = 0x1300; // enable emulation
FSTAT &= FSTAT_CCIF_MASK;
while(!(FSTAT & FSTAT_CCIF_MASK))
{
}
}
That's great!Thank for replying me!But a pity is that i check it out and think it's not the solution to my problem. In normal mode(i check the MODE Register value is 0x80),i follow your method that use the patition command -0x20,after invoking these codes ,i check register's messages,the results are: 1)FCCOBIX=0,->FCCOB=0x2000;2)FCCOBIX=1,->FCCOB=0; 3)FCCOBIX=2,->FCCOB=8, FSTAT=0x83.
But,when i set register-MMCCTL1-bit5 and read the address 0x120004 and 0x120005,the values still are 0x00, not change,so i think it's failure to execute the patition command, of course,i still can't use the eepom.
I think that the globle address 0x120000~0x120007 must be erased state before execute patition command,is it? How can i execute the patiton command successful in the normal mode?
I wish that you can continue to help me.
My routine shows how one could avoid partitioning in BDM mode (special single chip mode) and partition in normal mode. Once partitioning is done (like in your case), EEPROM query returns non-0xFFFF value, normal mode partition command (0x20) can not be used. Once partitioned in any mode (normal or special), you need to go to BDM mode and erase all DFLASH before commands 0xF or 0x20 can be used again.
Edward
Good afternoon! is it mean that i must go to BDM mode if i want to recover the EEPROM(once fault) function? I worry about that the same phenomenon(eeprom fault) would occur again.So i want there is a another way can recover EEPROM in normal mode. because of i am not sure that the wrong ERPART cased my problem, because my other boards are normal and they run the same application code.
I think by now you should worry about invalid ERPART value of 0x10. Perhaps with right ERPART value of <=8 you won't ever see this problem again?
And yes, you can't recover failed EEE without BDM mode. Using DFLASH directly without EEE layer could be another choice for you.
Regards
Edward
Hi Edward,
S12XET256 have 32kB D-Flash and 4kB buffer RAM, ERPART=16 and DFPART=0 should be OK.
Alex,
Few notes:
So, we should check whether (full) partition command was finished without interruption by some followed action (write flag to P-Flash, signalize to final test environment,…). Other option is check last sector header at address 0x107F00. For example:
if(*(unsigned int *far)0x107F00 == 0xFFFF) err = FORMAT_ERROR;
Unfortunately testing DFPART/ERPART is not enough since these values are written before D-Flash format.
In attachment you could find simple S12XE EEEPROM description and two simple example codes.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Radek ,
Thank you very much!
Perhapes as you indicate that patition command is interrupted and cause the problem ,though eeprom normal at beginning,but exist risk of breakdown. I also think that the most possibility of my problem is caused by unexpected mcu reset.once i make a few test that during pending eeprom datas force turn off the power,I can not see the same phenomenon,even i analyze maybe defect with my hardware ,In fact,no have external signals in FTM,so i do'nt know how to analyze it.
My purpose is that avoid the same problem occur again, prior ,i plan to find a method to repatition DFLASH and recover the eeprom, by sure the eeprom become error. but the application -level command(0x20) must be in the case that use the erase all bocks command(0x08 and available in special modes).
Of course,i should make lots of effors to improve my codes and try to see whether occur the same problem using the improved codes.
Alex.
Hi alex,
I could simply help you in case of partition command unexpected interrupt simulations.
I already created example code some time ago. Please look at attachment.
You could simply play with Start_interval() parameter and try simulate similar issue as in your case.
In root of project you could find examples of OK and NOK memory contents.
For recovery, please unsecure MCU and load code again, after that you could execute partition command once again.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Radek,
Sorry! Due to we are not belong to the same time zone,so i could not replay you fast. In fact,you have answered my question .I also need some time to check it out. so i will follow your suggestion that avoid patition be interrupted,and i will follow Edward's suggestion that make the ERPART small,I plan to use DFLASH directly and back up my important parameters to PFLASH.
Thank you(and Edward) very much!
Have a great day!
Alex
Hi alex,
According your colleague’s thread (https://community.freescale.com/thread/380574), re-partitioning didn’t help. So, problem will be probably somewhere else.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Sorry, those multipart datasheets are sometimes misleading, I was looking into S12XD128 chapter. But still ERPART should be kept as small as possible, matching required minimum of EEE size.
Regards,
Edward
Ed, no more coffee for today.
S12XD128 chapter in S12XE datasheet. ;-)
Anyway, your cooperation is really appreciated. Thank you very much.
Radek