AnsweredAssumed Answered

how to read and write EEPROM in S32R274

Question asked by piao bht on Mar 5, 2019
Latest reply on Mar 13, 2019 by piao bht

hello, there are some questions about how to use EEPROM in S32R274,

accroding to S32R274 Datasheet,I think I can rease and programe EEPROM,but how to read what I wirte?

I will appreciate for your answer.

next is my program,

 

/* Unlock mid block 0x00FB_8000 - 0x00FB_FFFF */
C55FMC.LOCK0.R &= 0xFFFFFDFF;


/* Erase the mid block */
C55FMC.MCR.B.ERS = 1;
C55FMC.SEL0.R = 0x00000200; /* Select the mid block */
*(unsigned int*)0x00FB8000 = 0xFFFFFFFF; /* Interlock write */
*(unsigned int*)0x00FB8004 = 0xFFFFFFFF;
*(unsigned int*)0x00FB8008 = 0xFFFFFFFF;
*(unsigned int*)0x00FB800C = 0xFFFFFFFF;
*(unsigned int*)0x00FB8010 = 0xFFFFFFFF;
*(unsigned int*)0x00FB8014 = 0xFFFFFFFF;
*(unsigned int*)0x00FB8018 = 0xFFFFFFFF;
*(unsigned int*)0x00FB801C = 0xFFFFFFFF;
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.ERS = 0;

 

/* Program one page in the mid block */
C55FMC.MCR.B.PGM = 1;
*(unsigned int*)0x00FB8000 = 0x11111111; /* Interlock write */
*(unsigned int*)0x00FB8004 = 0x22222222; /* Up to 8 words (one 256bit page) can be programmed at once */
*(unsigned int*)0x00FB8008 = 0x33333333;
*(unsigned int*)0x00FB800C = 0x44444444;
*(unsigned int*)0x00FB8010 = 0x55555555;
*(unsigned int*)0x00FB8014 = 0x66666666;
*(unsigned int*)0x00FB8018 = 0x77777777;
*(unsigned int*)0x00FB801C = 0x88888888;
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;

 

/*read*/
uint8_t ansa = (*(unsigned int*)0x00FB8000)>>24;

Outcomes