how to read and write EEPROM in S32R274

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

how to read and write EEPROM in S32R274

812 Views
bhtybyb
Contributor II

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;

Labels (1)
Tags (2)
0 Kudos
3 Replies

642 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

you use wrong bit for unlocking and wrong bit for selection of block for erase.

There's attached file S32R274_Flash_Block_Assignment_Rev7.xlx inside the reference manual. Open it and see tabs "NVM" and then "Lock Register Def.". You will see that address 0xFB8000 belongs to Block 3 and it's bit 3 in LOCK0 and in SEL0. You should write 0xFFFFFFF7 to LOCK0 and 0x8 to SEL0.

Then it will work as expected.

Regards,

Lukas

0 Kudos

642 Views
bhtybyb
Contributor II

Thanks for your reply, It is very help for me, Thanks again.

0 Kudos

642 Views
bhtybyb
Contributor II

the answer of read always is 0XFF.so where am I wrong .

0 Kudos