FSTAT : Protection Violation or Access Error EEPROM

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FSTAT : Protection Violation or Access Error EEPROM

486 次查看
skhwaja
Contributor I

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

0 项奖励
1 回复

398 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello,

At first, I recommend you look at the attached example codes for the S12XEP100 for emulated EEPROM. There you can find the settings of registers with the description.

The useful application notes AN3490 and AN3743:

AN3490 Overview of the MC9S12XE Emulated EEPROM

https://www.nxp.com/files-static/microcontrollers/doc/app_note/AN3490.pdf 

 

AN3743 Emulated EEPROM Quick Start Guide

https://www.nxp.com/files-static/microcontrollers/doc/app_note/AN3743.pdf 

https://www.nxp.com/docs/en/application-note-software/AN3743SW.zip 

 

I believe it helps you.

Best Regards,

Diana

0 项奖励