<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic S32K144 EEEPROM usage - No SDK in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K144-EEEPROM-usage-No-SDK/m-p/1842850#M33950</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;For my application, I need to read and write certain data from the s32k144 EEEPROM. I'm using EEEPROM code without SDK.&lt;/P&gt;&lt;P&gt;Configuration on debugger advanced option.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yuvashree_2-1712573109047.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/272501i98AC3553FF30CDE8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yuvashree_2-1712573109047.png" alt="Yuvashree_2-1712573109047.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I just manually modified these lines in the S32K144_64_flash.ld file.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yuvashree_3-1712573404101.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/272502iFB9015934751309B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yuvashree_3-1712573404101.png" alt="Yuvashree_3-1712573404101.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm just trying to write to EEEPROM using the code below.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
 * main implementation: use this 'C' sample to create your own application
 *
 */
#include "S32K144.h" /* include peripheral declarations S32K144 */
//#include "EEEPROM_io_control.h"
#include "clocks_and_modes.h"

#define USER_DATA_SIZE	32u

#define EEE_SUCCESS	0
#define EEE_ALREADY_ENABLED -1

#define DISABLE_INTERRUPTS() __asm volatile ("cpsid i" : : : "memory");
#define ENABLE_INTERRUPTS() __asm volatile ("cpsie i" : : : "memory");
typedef struct
{
	float p1;
	float p2;
	float p3;
	float p4;
	char ch;
	double d1;
	double d2;
	unsigned long runtime_sec;
	int i1;
	char user_data[USER_DATA_SIZE];
} eeerom_data_t;

__attribute__ ((section(".eeeprom"))) eeerom_data_t eeerom_data;

int EEE_Init()
{
	if ((FTFC-&amp;gt;FCNFG &amp;amp; FTFC_FCNFG_EEERDY_MASK) == 0U)
	{
		volatile int timeout;
		FTFC-&amp;gt;FCCOB[3]=0x80;	// Program Partition command
		FTFC-&amp;gt;FCCOB[2]=0x00;	// CSEc key size
		FTFC-&amp;gt;FCCOB[1]=0x00;	// Security flag extension - User Key verify only disabled
		FTFC-&amp;gt;FCCOB[0]=0x00;	// Load data int EEERAM in reset sequence
		FTFC-&amp;gt;FCCOB[7]=0x02;	// EEPROM data set size code - 4k
		FTFC-&amp;gt;FCCOB[6]=0x08;	// EEPROM backup size - 64k
		FTFC-&amp;gt;FSTAT |=  FTFC_FSTAT_CCIF_MASK;

		while ((FTFC-&amp;gt;FSTAT &amp;amp; FTFC_FSTAT_CCIF_MASK) == 0U)
		{
			timeout++;
		}
		/*FTFC-&amp;gt;FCCOB[3]=0x81;	// Progran command
		FTFC-&amp;gt;FCCOB[2]=0x00;	// FlexRAM used as EEEPROM
		FTFC-&amp;gt;FSTAT |=  FTFC_FSTAT_CCIF_MASK;
		while ((FTFC-&amp;gt;FSTAT &amp;amp; FTFC_FSTAT_CCIF_MASK) == 0U);
		{
			timeout++;
		}*/
	}
	else
		return EEE_ALREADY_ENABLED;

	return EEE_SUCCESS;
}
int EEE_Write_int32(int data, int* target)
{
	while ((FTFC-&amp;gt;FSTAT &amp;amp; FTFC_FSTAT_CCIF_MASK) == 0){}
	*target=data;
	return 0;
}
void WDOG_disable (void){
  WDOG-&amp;gt;CNT=0xD928C520;    /*Unlock watchdog*/
  WDOG-&amp;gt;TOVAL=0x0000FFFF;  /*Maximum timeout value*/
  WDOG-&amp;gt;CS = 0x00002100;   /*Disable watchdog*/
}

int main(void)
{
	WDOG_disable();
	SOSC_init_8MHz();       /* Initialize system oscilator for 8 MHz xtal */
	SPLL_init_160MHz();     /* Initialize SPLL to 160 MHz with 8 MHz SOSC */
	NormalRUNmode_80MHz();  /* Init clocks: 80 MHz sysclk &amp;amp; core, 40 MHz bus, 20 MHz flash */

	EEE_Init();
	DISABLE_INTERRUPTS();
	EEE_Write_int32(123456,&amp;amp;eeerom_data.i1);
	ENABLE_INTERRUPTS();
	while(1){}
	return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;Assist me in implementing a solution to write data into the EEEPROM and provide a function for retrieving data from it.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Apr 2024 04:25:10 GMT</pubDate>
    <dc:creator>Yuvashree</dc:creator>
    <dc:date>2024-04-09T04:25:10Z</dc:date>
    <item>
      <title>S32K144 EEEPROM usage - No SDK</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-EEEPROM-usage-No-SDK/m-p/1842850#M33950</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;For my application, I need to read and write certain data from the s32k144 EEEPROM. I'm using EEEPROM code without SDK.&lt;/P&gt;&lt;P&gt;Configuration on debugger advanced option.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yuvashree_2-1712573109047.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/272501i98AC3553FF30CDE8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yuvashree_2-1712573109047.png" alt="Yuvashree_2-1712573109047.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I just manually modified these lines in the S32K144_64_flash.ld file.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yuvashree_3-1712573404101.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/272502iFB9015934751309B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yuvashree_3-1712573404101.png" alt="Yuvashree_3-1712573404101.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm just trying to write to EEEPROM using the code below.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*
 * main implementation: use this 'C' sample to create your own application
 *
 */
#include "S32K144.h" /* include peripheral declarations S32K144 */
//#include "EEEPROM_io_control.h"
#include "clocks_and_modes.h"

#define USER_DATA_SIZE	32u

#define EEE_SUCCESS	0
#define EEE_ALREADY_ENABLED -1

#define DISABLE_INTERRUPTS() __asm volatile ("cpsid i" : : : "memory");
#define ENABLE_INTERRUPTS() __asm volatile ("cpsie i" : : : "memory");
typedef struct
{
	float p1;
	float p2;
	float p3;
	float p4;
	char ch;
	double d1;
	double d2;
	unsigned long runtime_sec;
	int i1;
	char user_data[USER_DATA_SIZE];
} eeerom_data_t;

__attribute__ ((section(".eeeprom"))) eeerom_data_t eeerom_data;

int EEE_Init()
{
	if ((FTFC-&amp;gt;FCNFG &amp;amp; FTFC_FCNFG_EEERDY_MASK) == 0U)
	{
		volatile int timeout;
		FTFC-&amp;gt;FCCOB[3]=0x80;	// Program Partition command
		FTFC-&amp;gt;FCCOB[2]=0x00;	// CSEc key size
		FTFC-&amp;gt;FCCOB[1]=0x00;	// Security flag extension - User Key verify only disabled
		FTFC-&amp;gt;FCCOB[0]=0x00;	// Load data int EEERAM in reset sequence
		FTFC-&amp;gt;FCCOB[7]=0x02;	// EEPROM data set size code - 4k
		FTFC-&amp;gt;FCCOB[6]=0x08;	// EEPROM backup size - 64k
		FTFC-&amp;gt;FSTAT |=  FTFC_FSTAT_CCIF_MASK;

		while ((FTFC-&amp;gt;FSTAT &amp;amp; FTFC_FSTAT_CCIF_MASK) == 0U)
		{
			timeout++;
		}
		/*FTFC-&amp;gt;FCCOB[3]=0x81;	// Progran command
		FTFC-&amp;gt;FCCOB[2]=0x00;	// FlexRAM used as EEEPROM
		FTFC-&amp;gt;FSTAT |=  FTFC_FSTAT_CCIF_MASK;
		while ((FTFC-&amp;gt;FSTAT &amp;amp; FTFC_FSTAT_CCIF_MASK) == 0U);
		{
			timeout++;
		}*/
	}
	else
		return EEE_ALREADY_ENABLED;

	return EEE_SUCCESS;
}
int EEE_Write_int32(int data, int* target)
{
	while ((FTFC-&amp;gt;FSTAT &amp;amp; FTFC_FSTAT_CCIF_MASK) == 0){}
	*target=data;
	return 0;
}
void WDOG_disable (void){
  WDOG-&amp;gt;CNT=0xD928C520;    /*Unlock watchdog*/
  WDOG-&amp;gt;TOVAL=0x0000FFFF;  /*Maximum timeout value*/
  WDOG-&amp;gt;CS = 0x00002100;   /*Disable watchdog*/
}

int main(void)
{
	WDOG_disable();
	SOSC_init_8MHz();       /* Initialize system oscilator for 8 MHz xtal */
	SPLL_init_160MHz();     /* Initialize SPLL to 160 MHz with 8 MHz SOSC */
	NormalRUNmode_80MHz();  /* Init clocks: 80 MHz sysclk &amp;amp; core, 40 MHz bus, 20 MHz flash */

	EEE_Init();
	DISABLE_INTERRUPTS();
	EEE_Write_int32(123456,&amp;amp;eeerom_data.i1);
	ENABLE_INTERRUPTS();
	while(1){}
	return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;Assist me in implementing a solution to write data into the EEEPROM and provide a function for retrieving data from it.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 04:25:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-EEEPROM-usage-No-SDK/m-p/1842850#M33950</guid>
      <dc:creator>Yuvashree</dc:creator>
      <dc:date>2024-04-09T04:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 EEEPROM usage - No SDK</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-EEEPROM-usage-No-SDK/m-p/1847108#M34212</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/229145"&gt;@Yuvashree&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The MCU should be partitioned only once in the lifetime of the device.&lt;/P&gt;
&lt;P&gt;It can be done using the PE Micro debugger as you showed.&lt;/P&gt;
&lt;P&gt;Please check the SIM_FCFG1[DEPART] register to confirm the partitioning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you decide to do it in the code, first read the DEPART register, and lauch the command only if the NVM has not been partitioned yet.&lt;/P&gt;
&lt;P&gt;Also, the command must be launched from SRAM.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielmartynek_0-1713182020595.png" style="width: 568px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/273750i95E927AF6617B262/image-dimensions/568x186?v=v2" width="568" height="186" role="button" title="danielmartynek_0-1713182020595.png" alt="danielmartynek_0-1713182020595.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 11:55:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-EEEPROM-usage-No-SDK/m-p/1847108#M34212</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2024-04-15T11:55:11Z</dc:date>
    </item>
  </channel>
</rss>

