Hello,
I am designing an application running on the S32K144-EVB that utilizes the EEEPROM. The application does not use the S32 SDK.
For preparation, I have read through the following documentation:
- A11983.pdf
- S32K-Reference Manual regarding EEEPROM, etc.
For actual development, I have referenced the following source code:
Thus far, I have successfully got the D-Flash E-Flash Partition working, using the launch flash command executed from SRAM and not from P-Flash. Furthermore, have executed the SETRAM command to make the FlexRAM available for Emulated EEPROM.
I receive the expected codes back when reading the following:
uint16_t s32k144_Dflash_Eflash_verify(void)
{
uint16_t depart_code = (uint16_t)((SIM->FCFG1 & SIM_FCFG1_DEPART_MASK) >> SIM_FCFG1_DEPART_SHIFT);
uint16_t eeeram_code = (uint16_t)((SIM->FCFG1 & SIM_FCFG1_EEERAMSIZE_MASK) >> SIM_FCFG1_EEERAMSIZE_SHIFT);
// depart_code = 8
// eeeram_code = 2
}
Have done the linker file changes to allocate 4 kilobytes at address 0x14000000. With these changes, all ground work is done to use EEEPROM.
The problem I'm experiencing is when writing to the FlexRAM area. The very first write straight after doing the D-Flash E-Flash Partitioning is successful where I assign an integer. Then after doing a reset and executing a EEEPROM write there after stalls the application. Interestingly, when a reset is done after the stalled application scenario, the EEEPROM write was successful as reading it back shows the intended value is read back.
The write functions confirm that CCIF = '1' and EEERDY = '1'
uint8_t s32k144_eeeprom_write_32bit(uint32_t* dest, uint32_t data)
{
if (!dest)
{
return EEE_PARAM_ERR;
}
if ((FTFC->FCNFG & FTFC_FCNFG_EEERDY_MASK) == 0UL)
{
return EEE_NOT_READY;
}
if ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0UL)
{
return EEE_BUSY;
}
if (data != *dest)
{
*dest = data; // calling this a second time around stalls the application
}
return EEE_SUCCESS;
}
Have tried nesting the above write functions in DISABLE_INTERRUPTS() and ENABLE_INTERRUPTS() but no difference in behavior.
Anything suggestions of other things to try or point of what I have missed would be much appreciated. I can provide a zip code example for debug purposes.
Regards,
Josh