using FlexRAM with MCAL EEP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using FlexRAM with MCAL EEP

Jump to solution
2,734 Views
talha_uyar
Contributor III

Hi,

I am trying to use MCAL EEP module to use the FlexRAM. I am using the S32K118 EVB and S32 Design Studio. 

I have made the configurations on EB Tresos, and tried to use the module. In my main function I have called the Eep_Init() function and Eep_AC_Callback(), Eep_StartEepromAccessNotif(), and Eep_FinishedEepromAccessNotif() callbacks are entered. 

Then I have set up a timer which calls Eep_Main_Function() at every second or so. I also called the Eep_Write() and Eep_GetJobResult() functions with a button push.

After I call Eep_Write() function and calling the Eep_Main_Function() and waiting for a while, I called Eep_GetJobResult() and it returned MEMIF_JOB_FAILED. 

In the Integration Manual of the EEP module, it is stated that 

The Eeprom memory physical sectors that are going to be modified by Eep driver (i.e. erase and write operations) have to be unprotected for a successful operation.
The FlexNVM memory has to be partitioned for EEPROM emulation.

and I simply haven't configured these as far as I can tell. Is this the reason? If so, how can I partition the FlexNVM for EEPROM emulation and make sure that the physical sectors are unprotected, using MCAL drivers?

Also, what are the differences between the EEP module and FLS/FEE modules? Should I use them instead of EEP? 

Thanks in advance,

Edit: After Eep_Init(), I checked the status with a timer at 1 second intervals, and it always returns MEMIF_UNINIT. So, I guess my issue is that I haven't configured Eep properly. How can I fix this?

Edit 2: I have looked at the example code provided here: EXAMPLE: S32K144 EEEPROM usage - No SDK.

When I call the following function after Mcu_Init(); Mcu_InitClock(); andMcu_SetMode(); I get a Hard Fault error.

uint8 EEE_Init()
{
if ((FTFC->FCNFG & FTFC_FCNFG_EEERDY_MASK) == 0U)
{
volatile int timeout;
FTFC->FCCOB[3]=0x80; // Program Partition command
FTFC->FCCOB[2]=0x00; // CSEc key size
FTFC->FCCOB[1]=0x00; // Security flag extension - User Key verify only disabled
FTFC->FCCOB[0]=0x00; // Load data int EEERAM in reset sequence
FTFC->FCCOB[7]=0x01; // EEPROM data set size code - 4k
FTFC->FCCOB[6]=0x08; // EEPROM backup size - 64k
FTFC->FSTAT |= FTFC_FSTAT_CCIF_MASK;

while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0U)
{
timeout++;
}
/*FTFC->FCCOB[3]=0x81; // Progran command
FTFC->FCCOB[2]=0x00; // FlexRAM used as EEEPROM
FTFC->FSTAT |= FTFC_FSTAT_CCIF_MASK;
while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0U);
{
timeout++;
}*/
}
else
{
return 1;
}

return 0;
}

Further debugging revealed that I get the Hard Fault error at the line FTFC->FSTAT |= FTFC_FSTAT_CCIF_MASK; 

Edit 3: After the Hard Fault error, I have checked FSTAT->FPVIOL and it is 0, which I think means there is no violation.

Edit 4: Ok, I have understood my error and fixed the Partitioning part to the code below and it is working fine now.

However, I still want to know whether it is possible to do this using MCAL drivers or not. Do I have to access the FTFC registers manually to use the EEP driver? Is there something I can use in the MCAL drivers for Partitioning?

if ((FTFC->FCNFG & FTFC_FCNFG_EEERDY_MASK) == 0U)
{
volatile int timeout;
FTFC->FCCOB[3]=0x80; // Program Partition command
FTFC->FCCOB[2]=0x00; // CSEc key size
FTFC->FCCOB[1]=0x00; // Security flag extension - User Key verify only disabled
FTFC->FCCOB[0] |= 0x00; // Load data int EEERAM in reset sequence
FTFC->FCCOB[7]=0x03; // EEPROM data set size code - 4k
FTFC->FCCOB[6]=0x03; // EEPROM backup size - 32k
FTFC->FSTAT |= FTFC_FSTAT_CCIF_MASK;
while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0U)
{
   timeout++;
}
Labels (1)
1 Solution
2,638 Views
hungnguyenphi
NXP Employee
NXP Employee

Hello  Muhammet Uyar,

I would like to answer your question:
Is this the reason? If so, how can I partition the FlexNVM for EEPROM emulation and make sure that the physical sectors are unprotected, using MCAL drivers?
[Hung] The MCAL driver have 3 module(EEP, FLS, CSEC) share some hardware resources of the FLEXNVM memory so several aspects need to be considered when using them together in the same application. User will need to consider it. So the EEP will not automatic partition the FlexNVM for EEPROM emulation. The MCAL driver also doesn't support partitioning the FlexNVM for EEPROM emulation and make sure that the physical sectors are unprotected. User will need to access FTFC register manually to partition the FlexNVM for EEPROM emulation.

what are the differences between the EEP module and FLS/FEE modules? Should I use them instead of EEP?
[Hung] The EEP use the FlexRAM as EEP ROM with Hardware support.
            The FEE/FLS emulates the EEP ROM uses Flash with software support.( For the devices without EEPROM memory, the block-erasable (or sector-erasable) flash memory can be used to emulate the EEPROM through EEPROM emulation software )

            User can choose EEP or FEE base on the application and hardware.

Best regards,

Hung.

View solution in original post

3 Replies
2,412 Views
riglesias2021
Contributor III

Hi! Could you share some info/code snippets/docs that you checked out to get EEP module working? I´m using S32K118 and i already partitioned the FlexNVM/FlexRAM, and now i need to get the eeprom working using the EEP module. 

 

Thank you!!!

0 Kudos
2,408 Views
riglesias2021
Contributor III

I would like to see an code example + tresos config of the EEP module working

0 Kudos
2,639 Views
hungnguyenphi
NXP Employee
NXP Employee

Hello  Muhammet Uyar,

I would like to answer your question:
Is this the reason? If so, how can I partition the FlexNVM for EEPROM emulation and make sure that the physical sectors are unprotected, using MCAL drivers?
[Hung] The MCAL driver have 3 module(EEP, FLS, CSEC) share some hardware resources of the FLEXNVM memory so several aspects need to be considered when using them together in the same application. User will need to consider it. So the EEP will not automatic partition the FlexNVM for EEPROM emulation. The MCAL driver also doesn't support partitioning the FlexNVM for EEPROM emulation and make sure that the physical sectors are unprotected. User will need to access FTFC register manually to partition the FlexNVM for EEPROM emulation.

what are the differences between the EEP module and FLS/FEE modules? Should I use them instead of EEP?
[Hung] The EEP use the FlexRAM as EEP ROM with Hardware support.
            The FEE/FLS emulates the EEP ROM uses Flash with software support.( For the devices without EEPROM memory, the block-erasable (or sector-erasable) flash memory can be used to emulate the EEPROM through EEPROM emulation software )

            User can choose EEP or FEE base on the application and hardware.

Best regards,

Hung.