read and write data of EEPROM of S32K144?

cancel
Showing results for 
Search instead for 
Did you mean: 

read and write data of EEPROM of S32K144?

936 Views
Contributor III

As i mentioned above, i need information how to access EEPROM and some information regarding partition of memory.

Regards,

Veeraju V Hallikeri

Tags (3)
20 Replies

27 Views
Contributor III

Hi sir,

EEPROM is working properly, I need information when data will write from Flex-RAM to Flex-NVM. Is it write immediately after writing data to the Flex-RAM or during Power OFF time?

is there any possibility to control data transfer from Flex-RAM to Flex-NVM?

Please help me for these two quarries.

Regards,

Veeraju V Hallikeri.  

0 Kudos

25 Views
NXP Employee
NXP Employee

Hello veerajuvh619@gmail.com‌,

Perhaps now it would be a good time to suggest that you try to post your SDK-related questions to the S32 SDK community: https://community.nxp.com/community/s32/s32sdk There are experts there who can help with these queries.

Best Regards,

Mike

0 Kudos

27 Views
Contributor III

Hi sir,

I read the description of example code in that they mentioned, flexNVM has used for EEPROM usage erase command will be blocked(sector erase and block erase).

Whether state machine automatically erase sectors or we need to write code?

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
Contributor III

Hi sir,

How to erase sector of s32k144 Flex NVM, Which SDK i have to use, if any example code please share to erase eeprom flexNVM.

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

Flash partitioning example from SDK RTM 3.0 contains Flash sector erase. You can use it as a reference. 

pastedImage_1.png

Jiri

0 Kudos

27 Views
Contributor III

Hi sir,

I used this for sector erase but it's showing status error.

address = flashSSDConfig.DFlashBase;
size = FEATURE_FLS_DF_BLOCK_SECTOR_SIZE;
ret = FLASH_DRV_EraseSector(&flashSSDConfig, address, size);
DEV_ASSERT(STATUS_SUCCESS == ret);

Please help me to erase eeprom sector.which SDK I have to use to erase sector of eeprom.


Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP TechSupport
NXP TechSupport

Hi Veeraju V Hallikeri,

Please refer the flash_partitioning_s32k144 example.

flash_partitioning_s32k144.png
You can read the "13.4.29 FLASH Partitioning" of S32SDK_S32K144_UserManual.(C:\nxp\S32DS_ARM_v2018.R1\S32DS\S32SDK_S32K1xx_RTM_3.0.0\doc)

FLASH Partitioning S32SDK_S32K144_UserManual.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

27 Views
Contributor III

Hi sir,

I checked with the example code the data is storing in flex-RAM and its not storing in E-flash(backup eeprom),how to store data in backup eeprom?

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

there is an example for EEEPROM - https://community.nxp.com/docs/DOC-340625 

Hope it helps. 

Jiri 

0 Kudos

27 Views
Contributor III

Hi sir,

I checked with "EEPROM usage code" i debugged with same code i am not getting data in E-flash memory, 

I followed the steps in the following way

-i build the code in debugger format

-then i selected debugger 

-in that i selected advanced options

-i configured same as you sent in picture and click on ok

-then debug

afterwords its showing like this

instead of 0204 can i give 020A for (flux-ram 2kb and E-flash 64kb)?

if i debug with another program the '0' values which are showing in the picture are also not getting ?

Screenshot (28).png

Screenshot (29).png

Please help me for finding solution.

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

FlexNVM is not accessible when used as backup flash for Emulated EEPROM. The only way how data can be accessed is via FlexRAM (0x14000000). 

Unfortunately - PE Micro is not able preserve FlexNVM - and when .elf file is changed - backup flash is cleared while target flashing. You can test if it works as expected by board reset and attaching to running target. Second option is using "Send HW Reset to target"

 

pastedImage_1.png

Jiri

0 Kudos

27 Views
Contributor III

Hi sir,

In that EEE size is showing 4096 (that means partition has been successfully done) the data will store in this successfully, but the data is not showing in backup eeprom is there any criteria to store data in backup eeprom ?

Screenshot (33).pngScreenshot (32).pngScreenshot (31).pngScreenshot (30).png

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

as I said above - when FlexNVM is configured as emulated EEPROM backup - it is not possible read data from that area even with debug probe. The only way how to check your data is by checking your mapped variables to FlexRAM or FlexRAM address in Memory view. 

Jiri

27 Views
Contributor III

Hi,

How can we map memory between flex-RAM and emulated eeprom?

How can i get data from different sectors of eeprom?

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

please see reference manual. Basically - Emulated EEPROM is FlexRAM with backup in FlexNVM. To be able use it by this way you need to partition FlexNVM. Transition between FlexRAM (configured as emulated EEPROM) to backup FlashNVM is done automatically by HW. Content of backup Flash is not accessible in this case and your values are visible in FlexRAM area. 

Anyway - this example doesn't work for you - https://community.nxp.com/docs/DOC-340625  ? 

Jiri

0 Kudos

27 Views
Contributor III

Hi sir,

That example work perfectly. Partition has been done(64kb of FlexNVM used as backup EEPROM).

i want to store fault details in 1st two sectors of EEPROM and other sectors for to store other details.

1. How can i map the address of EEPROM to store particular details?

2. After reset of controller(S32K144) at what address state machine will point? 

Is it point for starting address of FlexNVM or previous address itself.

Regards,

Veeraju V Hallikeri

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

in my opinion best way how to access your data is create structure and put it into FlexRAM section - for example like this: 

typedef struct
{
   int timestamp;

   char fault_details[256]

} fault_details_t;

typedef struct

{

   int timestamp;

   char runtime_data[256]

} runtime_data_t

put both structures into eeeprom area: 

fault_details_t fault_details __attribute__ ((section(".eeeprom")));

runtime_data_t runtime_data __attribute__ ((section(".eeeprom")));

In this case you don't need any address - you can normally read/write data like with normal structure. 

Don't forget define eeeprom section in linker file: 

pastedImage_1.png

pastedImage_2.png

After reset you find stored data in both structures. If you write new data into structure - data will be automatically stored in backup flash. After another reset - you will find new data in both structures. 

Jiri

27 Views
Contributor III

Hi sir,

I tried with this code by changing linker file but flow is going default ISR and I have one more quarry, I used condition but this condition will become true and then EEPROM READY resistor bit will set I am confused weather the partition is done successfully are not.

if(flashSSDConfig.EEESize == 0) 
{
ret = FLASH_DRV_DEFlashPartition(&flashSSDConfig, EEE_SIZE, EEE_BACKUP, 0x0u, false, true);
DEV_ASSERT(STATUS_SUCCESS == ret);
ret = FLASH_DRV_Init(&Flash1_InitConfig0, &flashSSDConfig);
DEV_ASSERT(STATUS_SUCCESS == ret);
ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL); /* flex Ram to flex NVM */
DEV_ASSERT(STATUS_SUCCESS == ret);
}

****************************************************************************************************************************************

                                                                                         code

****************************************************************************************************************************************

#include "Cpu.h"

volatile int exit_code = 0;
#define EEE_SIZE 0x02u
#define EEE_BACKUP 0x08u


typedef struct
{
int timestamp;
char fault_details[2];
} fault_details_t;

typedef struct

{
int timestamp;
char runtime_data[2];
} runtime_data_t;

fault_details_t fault_details __attribute__ ((section(".eeeprom")));

runtime_data_t runtime_data __attribute__ ((section(".eeeprom")));

flash_ssd_config_t flashSSDConfig;
status_t ret;

int main(void)
{
/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

CLOCK_SYS_Init(g_clockManConfigsArr,CLOCK_MANAGER_CONFIG_CNT,g_clockManCallbacksArr,CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
FLASH_DRV_Init(&Flash1_InitConfig0, &flashSSDConfig);
if(flashSSDConfig.EEESize == 0) 
{
ret = FLASH_DRV_DEFlashPartition(&flashSSDConfig, EEE_SIZE, EEE_BACKUP, 0x0u, false, true);
DEV_ASSERT(STATUS_SUCCESS == ret);
ret = FLASH_DRV_Init(&Flash1_InitConfig0, &flashSSDConfig);
DEV_ASSERT(STATUS_SUCCESS == ret);
ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL); /* flex Ram to flex NVM */
DEV_ASSERT(STATUS_SUCCESS == ret);
}

fault_details.timestamp = 10;
fault_details.fault_details[0] = 5;
runtime_data.timestamp = 20;
runtime_data.runtime_data[0] = 30;

/* For example: for(;;) { } */

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the NXP S32K series of microcontrollers.
**
** ###################################################################
*/

0 Kudos

27 Views
NXP Employee
NXP Employee

Hi, 

Do you know which line causes exception? You need to wait for EEEPROM readines between writes into FlexRAM: 

eeerom_data.p1=100.0;
while ((FTFC-> FSTAT & FTFC_FSTAT_CCIF_MASK) == 0){}
eeerom_data.p2=200.0;

Jiri

27 Views
Contributor III

Hi,Jiri Kral.

  • When I initialize EEPROM, the program always comes in fault,why?

/* Declare a FLASH configuration structure which is initialized by FlashInit, and will be used by all
flash APIs */
flash_ssd_config_t flashSSDConfig;

/*! @brief Configuration structure flashCfg_0 */
const flash_user_config_t Flash_InitConfig0 = {
.PFlashBase = 0x00000000U, /* Base address of Program Flash block */
.PFlashSize = 0x00100000U, /* Size of Program Flash block */
.DFlashBase = 0x10000000U, /* Base address of Data Flash block */
.EERAMBase = 0x14000000U, /* Base address of FlexRAM block */
/* If using callback, any code reachable from this function must not be placed in a Flash block targeted for a program/erase operation.*/
.CallBack = NULL_CALLBACK
};

FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig);
/* Config FlexRAM as EEPROM if it is currently used as traditional RAM */
if (flashSSDConfig.EEESize == 0u)
{
   /* Configure FlexRAM as EEPROM and FlexNVM as EEPROM backup region,
   * DEFlashPartition will be failed if the IFR region isn't blank.
   * Refer to the device document for valid EEPROM Data Size Code
   * and FlexNVM Partition Code. For example on S32K146:
   * - EEEDataSizeCode = 0x02u: EEPROM size = 4 Kbytes
   * - DEPartitionCode = 0x08u: EEPROM backup size = 64 Kbytes */
   FLASH_DRV_DEFlashPartition(&flashSSDConfig, 0x02u, 0x08u, 0x0u, false, true);

   FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig);

   /* Make FlexRAM available for EEPROM */
   FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL);
}
else/* FLexRAM is already configured as EEPROM */
{
   /* Make FlexRAM available for EEPROM, make sure that FlexNVM and FlexRAM
   * are already partitioned successfully before */
   FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL);
}

error message:

pastedImage_4.png

0 Kudos