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.

TM4C1290NCPDT: How to react to non-success returned from a call to EEPROMInit

Part Number: TM4C1290NCPDT

Hello all,

I am working to confirm that our firmware responds appropriately if it were to receive a failure code from the TI driver’s EEPROMInit function, and I have a question remaining in my mind still after reading the Data Sheet and Errata information that I’ve seen at https://www.ti.com/product/TM4C1290NCPDT#tech-docs   We are using Rev 3.

In the "Error During Programming" section within 8.2.4.1 of the Data Sheet, this information is presented:

After a reset and prior to writing any data to the EEPROM, software must read the EESUPP register and check for the presence of any error condition which may indicate that a write or erase was in progress when the system was reset due to a voltage drop. If either the PRETRY or ERETRY bits are set, the peripheral should be reset by setting and then clearing the R0 bit in the EEPROM Software Reset (SREEPROM) register and waiting for the WORKING bit in the EEDONE register to clear before again checking the EESUPP register for error indicators. This procedure should allow the EEPROM to recover from the write or erase error.  In very isolated cases, the EESUPP register may continue to register an error after this operation, in which case the reset should be repeated. After recovery, the application should rewrite the data which was being programmed when the initial failure occurred.

Now, for comparison, I will quote a portion of 8.2.4.2

Before writing to any EEPROM registers, the clock to the EEPROM module must be enabled through the EEPROM Run Mode Clock Gating Control (RCGCEEPROM) register (see page 388) and the following initialization steps must be executed:

1. Insert delay (6 cycles plus function call overhead).

2. Poll the WORKING bit in the EEPROM Done Status (EEDONE) register until it is clear, indicating that the EEPROM has completed its power-on initialization. When WORKING=0, continue.

3. Read the PRETRY and ERETRY bits in the EEPROM Support Control and Status (EESUPP) register. If either of the bits are set, return an error, else continue.

4. Reset the EEPROM module using the EEPROM Software Reset (SREEPROM) register at offset 0x558 in the System Control register space.

5. Insert delay (6 cycles plus function call overhead).

6. Poll the WORKING bit in the EEPROM Done Status (EEDONE) register to determine when it is clear. When WORKING=0, continue.

7. Read the PRETRY and ERETRY bits in the EESUPP register. If either of the bits are set, return an error, else the EEPROM initialization is complete and software may use the peripheral as normal.

When I read the two sections that I have highlighted, there appears to be a mismatch.  In the first section that I quoted, the gist seems to be that it’s appropriate to perform a soft reset of the EEPROM if there is an error encountered in PRETRY or ERETRY.  But in the list of numbered steps, there is a reset performed if there is not an error encountered in PRETRY or ERETRY. 

The reason why this is important to me is that I want to know what’s appropriate for our application to do if EEPROM_INIT_ERROR is returned from EEPROMInit.  If that error code has been returned at Step 3, then the first section that I quoted indicates that we should perform a soft reset and then try again.  (Per MEM#11 of the Errata for this device, we are using the TI driver implementation of EEPROMInit, rather than the ROM implementation.  I looked at the current driver code, and it seems to match the sequence of steps listed in section 8.2.4.2.  From the EEPROMInit driver source code, it looks like if we do not do that ourselves in our application, then the next call to EEPROMInit may well just early-exit at Step 3 again.) 

But on the other hand, given that MEM#11 exists, I wonder whether the "Error During Programming" passage of the Data Sheet (which obviously pre-dates MEM#11) is still regarded as correct?

Please could you give me some advice on this?  Should we take steps to perform that soft reset before making our next attempt to call EEPROMInit?  Part of me is wondering why, if this is still the recommended practice, the EEPROMInit driver itself does not take this action on the caller's behalf if this situation is encountered?

  • Hi,

      The EEPROMInit() already has the software reset inserted and it is correct.  After the reset, it is polling for the _EEPROMWaitForDone status just like in the beginning when EEPROMInit() is first called. 

    //
    // Make sure the EEPROM has finished any ongoing 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 initialization?
    //
    if(ui32Status & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY))
    {
    return(EEPROM_INIT_ERROR);
    }

    //
    // Perform a second EEPROM reset.
    //
    SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0);

    //
    // Wait for the EEPROM to complete its reset processing once again.
    //
    SysCtlDelay(2);
    _EEPROMWaitForDone();

    //
    // Read EESUPP once again to determine if any error occurred.
    //
    ui32Status = HWREG(EEPROM_EESUPP);

    //
    // Was an error reported following the second reset?
    //
    if(ui32Status & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY))
    {
    return(EEPROM_INIT_ERROR);
    }

    //
    // The EEPROM does not indicate that any error occurred.
    //
    return(EEPROM_INIT_OK);

  • Thank you for the reply, Charles.

    But I'm sorry I do not understand your explanation, because I am interested in what to do in the situation where either EEPROM_EESUPP_PRETRY or EEPROM_EESUPP_ERETRY is set.

    Although you have highlighted a section in red that certainly does indicate a reset, we will not (unless I am missing something) reach that code, because we have already returned out of the function by then, by virtue of this early-exit which is just above the code that you have highlighted in red.

    //
    // Did an error of some sort occur during initialization?
    //
    if(ui32Status & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY))
    {
    return(EEPROM_INIT_ERROR);
    }

    All the little voices in my head would be at peace if that early-exit clause instead looked like this:

    if (no error)

    {

      return EEPROM_INIT_OK;

    }

    This would mean that we go ahead and perform the reset if one of those bits is set, which would be aligned with the text in "Error During Programming" section of the documentation, but at odds with the steps outlined in 8.2.4.2.

    Thank you again for engaging!

    Cheers,

    Grant

  • Hi Grant,

      If the EEPROMInit fails to initialize due to an error then please follow section 8.4.2.1 to reset EEPROM before calling EEPROMInit again. 

  • Thank you Charles.  I will do that.