Petr Gaube

HCS08 reset when ERASE Flash

Discussion created by Petr Gaube on Dec 8, 2011
Latest reply on Dec 12, 2011 by bigmac

Hi,

when i try to ERASE only one sector of Flash, i get reset. I don't know why, i found a solution on this forum and google but with no solution. Interesting is that i try step the code and It will be pass. But when i just RUN the code. Reset comes.

 

E_FLASH_Result e_FLASH_WriteBlock(pu8 pu8_FlashPtr)/*****************************************************************************/{    /* Disable WATCHDOG */  //SOPT1_COPT = 0b00;  /* Wait for complete previous operation */  while (!FSTAT_FCCF) __RESET_WATCHDOG();                         /* DisableInterrupts */  _asm SEI;                                        /* ERASE FLASH SECTOR ------------------------------------------ */                                                                      /* Clear old error */     if (FSTAT_FACCERR == 1) FSTAT_FACCERR = 1;     /* Make sure command buffer is empty */  while(!FSTAT_FCBEF) __RESET_WATCHDOG();      *(pu8_FlashPtr) = 0xFF;  FCMD = 0x40;             /* Wait at least 4 cycles before clearing FCBEF */  _asm NOP;  _asm NOP;  _asm NOP;  _asm NOP;    /* Clear command buffer empty flag */  FSTAT_FCBEF = 1;       /* Check Access error */  if (FSTAT_FACCERR) {    FSTAT_FACCERR = 1;    return FSTAT_FACCERR;  }         /* Check Write error */  if (FSTAT_FPVIOL) {    FSTAT_FPVIOL = 1;    return FLASH_FPVIOL;  }      /* Wait for command completion or error */  do {    __RESET_WATCHDOG();  } while ((FSTAT & 0x70) == 0);          return FLASH_OK;}

 Thank you for any ideas.

Outcomes