AnsweredAssumed Answered

S32K144 EEEPROM - Fighting to get this working

Question asked by brucebowling on May 15, 2019
Latest reply on May 17, 2019 by brucebowling

I am attempting to enable EEE emulation mode on a S32K144 device (non-SDK). I have reviewed the appnote AN11983 and have searched the forums for this subject and have studied the various example code presented here.

 

My issue is that I can run the EEE initialization to put the device into EEE mode (checked with DEPART bits in SIM->FCFG1 not equal to 15, and verified with the bits in the FTFC->FCNFG register EEERDY = 1 and RAMRDY = 0 after executing).

 

However, on a power recycle the device reverts back to non-EEE mode - DEPART becomes 15 and EEERDY = 0 and RAMRDY = 1 ... in other words it reverts back to traditional RAM and not emulated EEPROM. The device "loses" the partition on powerup for some reason. I am not working with any other flash memory operation/operation.

 

I have told the P&E debugger to not erase the memory range and preserve the data in this range, however on every reload of code the chip is back to being traditional RAM. Same thing with power cycles, the device totally forgets it is in EEE mode and the stored data are lost (I verify this by sending the register contents out over a UART link).

 

I can single-step the initialization code below in the debugger and see that the chip is partitioned and returning the expected results for EEERDY (=1) and RAMRDY (=0), and the DEPART value becomes 4 - the UART link also returns the same. But cycle the power and the configuration is lost - the values are not "sticking" on a POR.

 

Here is my code... first, the calling section within main that checks DEPART and calls the EEE Init if device is not in EEE emulation mode:

 

    // Extract the DEPART value to see if chip is partitioned.
    // A value of 15 means that device is not partitioned....
    depart = (SIM->FCFG1 & SIM_FCFG1_DEPART_MASK) >> SIM_FCFG1_DEPART_SHIFT;

 

    if(depart == 15)
    {
        iEEE = EEE_init();
        depart = (SIM->FCFG1 & SIM_FCFG1_DEPART_MASK) >> SIM_FCFG1_DEPART_SHIFT;
    }

 

Here is the EEE init function that is called to place the device into EEE mode:

 

uint32_t EEE_init(void)
{
    // If the RAMRDY bit is zero then this part has been partitioned and the
    // RAM is in EEPROM emulation mode, so no config is needed, just exit.
    if((FTFC->FCNFG & FTFC_FCNFG_RAMRDY_MASK) == 0)
    {
        return(1);
    }

    // Next, the following checks to see if EEERDY flag is high... high means that this silicon has
    // already been partitioned and that we are all ready to go, no need to partition again.
    if(((FTFC->FCNFG & FTFC_FCNFG_EEERDY_MASK) >> FTFC_FCNFG_EEERDY_SHIFT)!= 0U)
    {
        return(2);
    }

    // So, if we get here then we have a brand new fresh silicon chip here that needs to be partitioned to
    // act in EEprom emulation mode, which is RAM that behaves like non-volatile memory.
    FTFC->FCCOB[3] = 0x80;    // FCCOB0: Selects the PGMPART program partition command
    FTFC->FCCOB[2] = 0x00;    // FCCOB1: No CESc operation
    FTFC->FCCOB[1] = 0x00;    // FCCOB2: No CESc operation
    FTFC->FCCOB[0] = 0x00;    // FCCOB3: FlexRAM loaded with valid EEPROM data during reset
    FTFC->FCCOB[7] = 0x02;    // FCCOB4: EEPROM data size: EEESIZE = 2 which is 4kB
    FTFC->FCCOB[6] = 0x04;    // FCCOB5: Flexram partition code - DEPART = 4

    FTFC->FSTAT |= FTFC_FSTAT_CCIF_MASK;    // Fire off the command

    while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0U);    // wait till done with command

    // Next, configure FlexRAM to act like emulated EEPROM - command code of 0x00 will:
    // - Clear the RAMRDY and EEERDY flags, then
    // - Write all ones to all flexram locations, then
    // - Copy down the existing EEPROM data into FlexRAM, then
    // - Set the EEERDY flag
    // (according to AN11983 the device is already in this mode by default,
    // so this is redundant....)
    FTFC->FCCOB[3] = 0x81;    // FCCOB0: Selects the SETRAM command
    FTFC->FCCOB[2] = 0x00;    // FCCOB1: Make FlexRAM available as emulated EEPROM

    FTFC->FSTAT |= FTFC_FSTAT_CCIF_MASK;    // Fire off the command

    while (((FTFC->FCNFG & FTFC_FCNFG_EEERDY_MASK) >> FTFC_FCNFG_EEERDY_SHIFT) == 0U);    
// wait till EEE is ready

    return(0);
}

 

I have been struggling with this for a long time without resolution. Any ideas?

 

- Bruce

Outcomes