Hello engineers,
I am using MPC5746 micro controller.I need to write one 32 bit variable in to eeprom through my program.I know its memory location,and its 0x00800000 to 0x00803FFF. Any one can tell me how to write to this memory location in eeprom.Any one can share an example code. Please give your valuable comments...Thank you
Hi,
there are three options:
1. Use SSD flash driver:
http://www.nxp.com/assets/downloads/data/en/device-drivers/C55_JDP_SSD.exe
User manual and examples are included in the package.
I shared simple example using SSD flash drivers here:
2. Use EEPROM Emulation driver:
http://www.nxp.com/assets/downloads/data/en/device-drivers/MPC5xxx_EEE_DRIVER.exe
3. And the last option - write own functions for flash programming. I shared simple example here (it's the same example like above, just without the drivers):
https://community.nxp.com/docs/DOC-105380
Regards,
Lukas
Hello, Lukas,
I'm using EEPROM Emulation on MPC5744P. Now I have met a problem.
Before eeprom initialization, I have a program with run time 5ms, but after initialization, I need 14ms-15ms to finish the program. Have you ever met these kind of problems? Could you please give me some suggestions to solve this problem?
Thank you.
This picture is before initialization
This picture is after initialization
Hi,
it's not clear to me. Do you mean that init_eeprom adds significant delay? You can check the source code, there may be a lot of things to be done. Or do you mean that the execution time of other functions gets longer? In this case, it would require more debugging to find what takes more time. One option is to toggle a pin at beginning and at end of each function (you can use different pins) and check them by scope to find the root cause.
Regards,
Lukas
Thank you Lukas, I think its better to use 3rd option.Thanks for your support. i have one more doubt can we write a variable to an uninitialized memory directly by using its address using pointer?
eg : int*nb=(int*)0x00800000;
*nb=a0;
here the value in variable a0 will write to address 0x00800000 or not?
Hi,
you need to follow the sequence described in reference manual. This is procedure for program operation:
.
And this is implementation of the procedure in my SW example which I shared earlier:
//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;
Regards,
Lukas
Thanks you Lukas.I read it and now more clear,Please find the following modified code :
I am going to write 3 values that are saved in 3 globally declared 32 bit variables uint32_t a0,a1,a2 ;
C55FMC.MCR.B.PGM = 1;
unsigned int *nb=(unsigned int*)0x00800000;
*nb=a0;
nb++;
*nb=a1;
nb++;
*nb=a2;
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;
No problem here. Just be aware that these two double words must be in erased state because cumulative programming is not allowed. If these two double words are not erased, it is necessary to erase whole 16KB block.
Regards,
Lukas
Hi Lukas,
I am using MPC5744 micro controller.I can successfully write data at 0x800000 addresses,but when I restart the power after reading out the data 0xFF. I was debugging in the S32DS to determine the success of the write.
The code is as follows:
C55FMC.MCR.B.PGM = 1;
*(uint8*)(0x800000) = 0x11;
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.PEG = 1;
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;