This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
We are planning to use Tiva TM4C1231H6PM in our design.
We are referring Tiva TM4C1231H6PMIR (Revision 15033.2672, July 16 2013)
We came across following explanation for power failure recovery mechanism for Internal EEPROM of TM4C1231H6PM in Datasheet
If the copy buffer itself is full, then it must first be erased, which adds extra time. The EREQ bit in the EESUPP register is set if the copy buffer must be erased. If so, the START bit can be written by the application to force the erase at a more convenient time. The EEDONE and EEINT registers can be used to detect completion.
A normal write performs two underlying writes: the control word write and the data write. If the control word writes but the data fails (for example, due to a voltage drop), the overall write fails with indication provided in the EEDONE register. Failure and the corrective action are broken down by the type of operation:
We came across following function from library, which handles the power failure recovery for Internal EEPROM of TM4C1231H6PM
EEPROMInit(void)
{
uint32_t ui32Status;
// Insert a small delay (6 cycles + call overhead) to guard against the possibility that this function is called immediately after the EEPROM peripheral is enabled. Without this delay, there is a slight chance that the first EEPROM register read will fault if you are using a compiler with a ridiculously good optimizer!
SysCtlDelay(2);
// Make sure the EEPROM has finished its reset processing.
_EEPROMWaitForDone();
// Read the EESUPP register to see if any errors have been reported.
ui32Status = HWREG(EEPROM_EESUPP);
// Did an error of some sort occur during a previous attempt to write to the EEPROM?
if(ui32Status & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY))
{
// Perform a second reset to allow the EEPROM a chance to correct the errors.
SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0);
// Wait for the EEPROM to complete it's reset processing once again.
SysCtlDelay(2);
_EEPROMWaitForDone();
// Read EESUPP once again to determine if the error conditions are cleared.
ui32Status = HWREG(EEPROM_EESUPP);
if(ui32Status & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY))
{
return(EEPROM_INIT_ERROR);
}
else
{
return(EEPROM_INIT_RETRY);
}
}
// The EEPROM does not indicate that any error occurred.
return(EEPROM_INIT_OK);
}
Our queries
Thanks in advance.....
Hello Yogesh,
1. The PRETRY and ERETRY require clean up the user code. The EREQ bit only tells that an Erase is required and will be done by the EEPROM controller the next time a word is programmed
2. Yes, it is the SW responsibility to clean up EEPROM. The SysCtlPeripheralReset is in sysctl.c file in TIVAWare driverlibs
3. (a) The role of the SW is to make sure that the EEPROM word did get written
3. (b) No. The SW has to make this decision.
3. (c) There is a very narrow window for this to happen. if it happens then it is difficult to predict. Thus to ensure consistency, before comitting the word to EEPROM, the Hibernate Battery backed Memory can be written to and then EEPROM write to be done, so that the SW can check for consistency.
3. (d) Same as above.
Regards
Amit
Hi Amit,
Thanks for the reply.
Your reply cleared our doubts regarding the power failure recovery of the internal eeprom of TIVA microcontroller.
Only one confusion is reagrding the handling of the EEPROM_EESUPP_PRETR and EEPROM_EESUPP_ERETRY flag.
As per description it is required to set the START flag of EESUPP register.
Setting of START flag of EESUPP register, we are not able to locate in function SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0). Please help us to locate same.
Thanks in advance....
Yogesh
Hello Yogesh,
The function SysCtlPeripheralReset is in driverlib/syscth.c ( and driverlib/sysctl.h) of the TIVAWare installation
The EEPROM functions would be driverlib/eeprom.c and .h
As for as the START bit in EESUPP that has to be done by the application code
Regards
Amit