Roy Chen

launch flash command,   fallowing program cann't be executed

Discussion created by Roy Chen on Apr 7, 2012
Latest reply on Apr 11, 2012 by Roy Chen

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!!!!

Outcomes