S12XEP100 EEPROM sometimes gets dirty

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

S12XEP100 EEPROM sometimes gets dirty

984 次查看
Rhapsody
Contributor III

Dear All,

I've developed a firmware that makes use of the internal S12XEP100 EEEPROM.

Everything works 99% of the time, but sometimes, after a power cycle, the EEEPROM is set to random values.

 

Here there is the init procedure, that is called without interrupt enable, after having set the clock:

 

void E3PROM_setup() {    e3prom_query();    if (erpart == 0xffff || dfpart == 0xffff) {        e3prom_dflash_partition();   }   e3prom_enable();  }

 

Where:

 

e3prom_query is used to retrive parameters from the e3prom

 

void e3prom_query() {   FSTAT = 0x30;   e3prom_wait();   FCCOBIX = 0;   FCCOBHI = 0x15;   FCCOBLO = 0x00;   FSTAT = 0x80;   e3prom_wait();   FCCOBIX = 1;   dfpart = FCCOB;   FCCOBIX = 2;   erpart = FCCOB;   FCCOBIX = 3;   ecount = FCCOB;   FCCOBIX = 4;   deadcnt = FCCOBHI;   rdycnt = FCCOBLO; }

 

e3prom_wait is used to wait for e3prom operations complete

 

void e3prom_wait() {   while((ETAG > 0) || (FSTAT_MGBUSY == 1) || FSTAT_CCIF == 0); }

 

e3prom_dflash_partition is used to partition the dflash

 

void e3prom_dflash_partition() {   FSTAT = 0x30;   e3prom_wait();   FCCOBIX = 0;   FCCOBHI = 0x20;   FCCOBLO = 0x00;   FCCOBIX = 1;   FCCOB = 0x0040;   FCCOBIX = 2;   FCCOB = 0x0004;   FSTAT = 0x80;   e3prom_wait(); }

 

void e3prom_enable() {   FSTAT = 0x30;   e3prom_wait();   FCCOBIX = 0;   FCCOBHI = 0x13;   FCCOBLO = 0x00;   FSTAT = 0x80;   e3prom_wait(); } 

 

And these are the routines to read and write:

 

void E3PROM_set_byte(unsigned long addr, byte val) {   byte * __far ptr = (byte * __far)addr;   *ptr = val; } byte E3PROM_get_byte(unsigned long addr) {   byte * __far ptr = (byte * __far)addr;   return *ptr; } 

 

Unfortunately the problem is happening very rarely and it cannot be reproduced sistematically.

Any hint or suggestion on the code above?

Am I wrong in something?

 

Many thanks in advance,

Ale

标签 (1)
0 项奖励
回复
2 回复数

612 次查看
DPB
NXP Employee
NXP Employee

Hello

On early versions of this device there was an errata with symptoms similar to this.

Are you using the maskset 5M48H?

If not, this could well be associated with the errata listed as MUCts03976 in the Mask Set Errata:

http://cache.freescale.com/files/microcontrollers/doc/errata/MSE9S12XEP100_4M48H.htm?fasp=1&WT_TYPE=...

The errata details also include workaround measures that may be useful.

612 次查看
Rhapsody
Contributor III

Thank you very much for having pointed me to that page, It's been very useful.

Now I'll check if the MCUs we had problem with have that maskset.

Thanks again,

Ale

0 项奖励
回复