EEPROM erase/ write problem

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

EEPROM erase/ write problem

2,588 次查看
rdkarthik
Contributor I
Hello All,
 
I am using a 9s12dg128 controller and P&E ICD. The EEPROM erase and write routines work fine as long as the BDM is connected and debugger is running, but fails to do so otherwise.
 
I use a 16Mz oscillator. I have also tried initializing EEPROM related registers the way codewarriror erase command does. There are no protection or access errors. EEPROM is readable. Disabled COP. Disabled PLL. Tried different values of ECLKDIV within range.  But nothing seems to work.I was not able to gather anything specific to this problem from the datasheets or errata either.
 
Any help would be appreciated.
 
Thanks in advance.
 
 
Karthik.
标签 (1)
0 项奖励
回复
1 回复

835 次查看
Lundin
Senior Contributor IV
Maybe you are writing to ECLKDIV more than once? In that case you would get the behaviour you describe since that register is "write once" in normal single chip mode, ie when the BDM isn't connected to put the mcu in special single chip mode.

And then you would get the wrong ECLKDIV and the eeprom won't work. I once made that mistake myself:

/* bad */
ECLKDIV = calculated_value;
ECLKDIV |= PRDIV8;

/* good */
ECLKDIV = calculated_value | PRDIV8;
0 项奖励
回复