mpc5744 eeprom

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

mpc5744 eeprom

2,432 Views
burnyfu
Contributor II

Hi all,

    I am using MPC5744 micro controller.I can successfully write data at 0x800000 addresses,.The code is as follows:

C55FMC.LOCK0.R &= 0xFFFEFFFF;
C55FMC.MCR.B.ERS = 1;
C55FMC.SEL0.R = 0x00010000; //select the mid block
*(unsigned int*)0x00800000 = 0xFFFFFFFF; //interlock write
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.ERS = 0;

C55FMC.MCR.B.PGM = 1;

 *(unsigned int*)0x00800000 = 0x11111111;

C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;

But what should i do when I want to save other data? Do I need to erase the flash again when I write the data again?

Can you help me solve this problem?

Labels (1)
0 Kudos
Reply
5 Replies

1,633 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

an aligned double word must be in erased state (all bytes are 0xFF) if you want to program it. So, if you want to re-program double word which has been already programmed, it is necessary to erase whole block.

If you want to write to next address (next double word) which is in erased state then:

C55FMC.MCR.B.PGM = 1;

 *(unsigned int*)0x00800008 = 0xAAAAAAAA;

 *(unsigned int*)0x0080000C = 0xBBBBBBBB;

C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;

Regards,

Lukas

0 Kudos
Reply

1,633 Views
feigao
Contributor I

Hi,Lukas

I program the eeprom as you said,but when I read the address 0x00817C00,the value is 0.

I also found that when I debug the project,the eeprom address 0x00817C00 was not erase by the S32 Design Studio,

Can you help me about this?

Thank you!

0 Kudos
Reply

1,633 Views
burnyfu
Contributor II

Thank you very much for your time Lukas. It has been a great help!

when i write to next address (next double word) which is in erased state whether the value of the 0x00800000 address is set to 0xffffffff?

0 Kudos
Reply

1,633 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

No, it's not erased. You would have to erase whole block.

Regards,

Lukas

0 Kudos
Reply

1,633 Views
burnyfu
Contributor II

Hi,Lukas

Before I change the value in address 800000, I need to wipe the whole block. At this time, the data in the adjacent address will be erased. Do I need to write the relevant data in the whole block every time I write it?

0 Kudos
Reply