MPC5634M programming the flash array0

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

MPC5634M programming the flash array0

435 Views
sufree
Contributor II

Hi,

    I learn to write MPC5634M programming the flash ,the program about array1 and array 2 can work.but the program about

array0 cannot work.the follow is my code :

in lcf:

MEMORY
{
myram: org = 0x40018000, len = 0x00001000

}

GROUP : {

.my_ram (VLECODE): { //instruction mode VLECODE has to mentioned

*(.myCodeInRAM)
}
} > myram

 

in main.c

#pragma section ".myCodeInRAM" code_mode=far_abs //For routines code_mode need to be mentioned
__declspec(section ".myCodeInRAM") void Program_FLASH_A0(void);


__declspec (section ".myCodeInRAM") void Program_FLASH_A0(void) //this program is for Array0,block 0
{

/* enable high address space*/
CFLASH0.LMLR.R = FLASH_LMLR_PASSWORD; // unlock register
CFLASH0.LMLR.R = 0x00000000; // unlock all LOW and MID blocks

CFLASH0.SLMLR.R = 0xC3C33333; // unlock register
CFLASH0.SLMLR.R = 0x00000000; // unlock all LOW and MID blocks

/* step1. erase block 0 (0x00000-0x4000) */
CFLASH0.MCR.B.ERS = 1; // select operation (erase)
//CFLASH0.LMSR.B.LSEL = 0x80; // select LOW block
// LSEL[7–0] apply to blocks 5, 4, 3, 2b, 2a, 1b, 1a and 0,
CFLASH0.LMSR.R = 0x00000080; // select MID block
//MSEL[1–0] apply to blocks 7 and 6
*((unsigned int*) 0x00038928) = 0xFFFFFFFF; // interlock write
CFLASH0.MCR.B.EHV = 1; // start the erase operation
while(CFLASH0.MCR.B.DONE == 0){}; // wait for DONE
CFLASH0.MCR.B.EHV = 0; //operation end
CFLASH0.MCR.B.ERS = 0; //deselect operation

/* step2. program data */
CFLASH0.MCR.B.PGM = 1; // select operation
*((unsigned int*) 0x00038928) = 0x66AA66AA; // first write
*((unsigned int*) 0x00038932) = 0x11BB11BB; // additional write
//*((unsigned int*) p_test++) = data_to_be_written[2]; // additional write
// *((unsigned int*) p_test) = data_to_be_written[3]; // additional write
CFLASH0.MCR.B.EHV = 1; //start the operation
while(CFLASH0.MCR.B.DONE == 0){}; //wait for DONE
status=CFLASH0.MCR.R&0x00000200;
CFLASH0.MCR.B.EHV = 0; //operation end
CFLASH0.MCR.B.PGM = 0; //deselect operation
}

 

And when i debug the program directly go to:161333_161333.pngQQ图片20160904211500.png

Original Attachment has been moved to: flash_0.rar

0 Kudos
0 Replies