hello, i have a MPC5748G microcontroller. i just want to know how can i store data or an array in its flash memory. if you can please suggest some example codes i would really appreciate it.
Hi,
If you use SDK, take a look at these examples:
c:\NXP\S32DS_Power_v2.1\S32DS\software\S32_SDK_S32PA_RTM_3.0.3\examples\MPC5748G\demo_apps\eeprom_emulation\
c:\NXP\S32DS_Power_v2.1\S32DS\software\S32_SDK_S32PA_RTM_3.0.3\examples\MPC5748G\driver_examples\system\flash_program_erase\
The documentation can be found here:
c:\NXP\S32DS_Power_v2.1\S32DS\software\S32_SDK_S32PA_RTM_3.0.3\doc\S32SDK_MPC5748G_UserManual.pdf
If you don’t use SDK, here’s an example which does not use drivers:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5748G-Flash-RW/ta-p/1123178
And here’s an example which uses older SSD flash drivers:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5748G-Flash-RW-SSD/ta-p/1129258
SSD flash driver can be downloaded here:
https://www.nxp.com/webapp/Download?colCode=C55_NVM_SSD
Emulation EEPROM driver can be downloaded here:
https://www.nxp.com/webapp/Download?colCode=MPC5XXX_EEE_DRIVER
But notice that SDK is preferred. These two drivers above are not maintained anymore.
Regards,
Lukas
ok im using the example code (
If you don’t use SDK, here’s an example which does not use drivers:
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5748G-Flash-RW/ta-p/1123178
)
i have written the following code:
//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
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
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;
i have nothing changed in the memory as follows
This code works as expected, I tested it.
Make sure that the data cache is either disabled or that it is invalidated after these flash operations.
Regards,
Lukas