hi. i have a problem.
After i launch flash commad. the fallowing program cann't be executed( i use LED_OFF to indicate command complete, but LED do not off, and interrupt cann't enable ). so i have to reset my MCU. and after reset, the flash command is executed Successfully.
fallowing is my code:
LED_ON(D27);
if(!FCLKDIV_FDIVLD){
FCLKDIV = 0x03;
}
while(!FSTAT_CCIF)
;
if(( FSTAT_ACCERR || FSTAT_FPVIOL )){
FSTAT = 0x30;
}
FCCOBIX = 0;
FCCOB = 0x0A7F; /*erase sector */
FCCOBIX = 1;
FCCOB = 0x4000;
Erase_ROM();
LED_OFF(D27);
#pragma CODE_SEG __NEAR_SEG ramcodeseg
void Erase_ROM(void) {
asm
{
PSHC // remember I-bit state
SEI // disable interrupts
}
FSTAT = 0x80; //launch command
while(!FSTAT_CCIF); //wait for done
asm PULC; // restore I-bit
}
#pragma CODE_SEG DEFAULT
can anyone helps me?thanks!!!!
Did you check what address Erase_ROM is allocated at? In case ramcodeseg placement is not defined in PRM file, Erase_ROM probably ends in flash, which is wrong. Your PRM file should have line like below in the PLACEMENT section:
ramcodeseg INTO RAM;
hi! thank you for your help!
fallowing is my prm file:
RAM2 = READ_WRITE 0x3000 TO 0x3FFF ALIGN 2[1:1];
ramcodeseg INTO RAM2;
fallowing is my map file:
Name Module Addr hSize dSize Ref Section
Erase_ROM 2000 F 15 2 ramcodeseg
is there any else possible error?
hi! i think i have no error in prm file.
could you give me more suggestion to solve my problem?
my flash command can be accomplish, but fallowing line in program can not be execute.
thank you very much!!!!!!!
Do you have no warning about missing prototype? Are Erase_ROM and surrounding __NEAR_SEG block #pragmas defined before Erase_ROM is called? It is not enough to put just prototype above caller. It may be that Erase_ROM is called with CALL instruction, while it returns with RTS...
hi!
you are right!! it works!!
i use "FAR_SEG" replace "NEAR_SEG"
#pragma CODE_SEG __FAR_SEG ramcodeseg
thank you!!!
sorry, i forgot to mention that my MCU is MC9S12XF512