I learned from the MPC5606S reference manual that the first 8KB of the Test falsh block may be used for user defined functions. I can read it now ,but I want to know how to program it?
here is simple example:
/* unlock all blocks */ CFLASH0.LML.R = 0xA1A11111; /* write password */ CFLASH0.LML.R = 0x00000000; /* unlock all low and mid blocks including test flash primary */ CFLASH0.SLL.R = 0xC3C33333; /* write password */ CFLASH0.SLL.R = 0x00000000; /* unlock all low and mid blocks including test flash secondary */
/* program double word to User OTP area of CFLASH0 */ CFLASH0.MCR.B.PGM = 1; *(unsigned int *)0x00400000 = 0x11223344; /* interlock write */ *(unsigned int *)0x00400004 = 0x55667788; /* program data write */ CFLASH0.MCR.B.EHV = 1; while(CFLASH0.MCR.B.DONE == 0); CFLASH0.MCR.B.EHV = 0; CFLASH0.MCR.B.PGM = 0;
Notice that this is OTP area, it can't be erased.
Retrieving data ...