我现在在 写 MPC5634M擦写读FLASH的驱动 MPC5634M programming the flash array0其中的array1和2的写出来都没问题,就是array0的一直运行不了。网上说要把程序放到RAM里面去,我也这么写了,还是不行,不知道哪里出了问题,哪位能指点迷经的,万分感谢
下面是我写的程序;
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
} 我调试的时候,程序直接跳进:
|