EEPROM erase/ write problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

EEPROM erase/ write problem

2,087 Views
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.
Labels (1)
0 Kudos
1 Reply

334 Views
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 Kudos