AnsweredAssumed Answered

FSTAT : Protection Violation or Access Error EEPROM

Question asked by Sarfraz K on Nov 25, 2018
Latest reply on Nov 26, 2018 by Diana Batrlova

Hello All,

 

I am trying to save data to the emulated EEPROM in the mc9s12xep100mag controller. While debugging I see that the FSTAT has CCIF and ACCER bits 1 (FSTAT = 0xa0) even though I am trying to set it to 0x80. I was wondering what could be the reason for having an access error and how to go about solving it.

 

if (FSTAT_CCIF == 0U) {              /* Is command complete ? */
    return ERR_BUSY;                   /* If yes then error */
  }
  /* FSTAT: ACCERR=1,FPVIOL=1 */
  FSTAT = 0x30U;                       /* Clear error flags */
  FCCOBIX = 0U;                        /* Clear index register */
  FCCOBHI = 0x12U;                     /* Erase D-Flash sector command */
  FCCOBLO = (byte)(((dword)Addr) >> 16); /* High address word */
  FCCOBIX++;                           /* Shift index register */
  FCCOB = (word)(((dword)Addr) & 0xFFFFFFFEUL); /* Low address word aligned to word*/
  FSTAT = 0x80U;                       /* Clear flag command buffer empty */
  while (FSTAT_CCIF == 0U) {}          /* Wait to command complete */
  if ((FSTAT & 0x23U) != 0U) {         /* Is access error or other error detected ? */
    return ERR_NOTAVAIL;               /* If yes then error */
  }
  return ERR_OK; 

 

The FSTAT & 0x23 always is non-zero resulting (as FSTAT is 0xa0) resulting in getting Error.

 

Please advice.

 

Best Regards

Outcomes