I am developing code for a hand-held product that uses the MC9S12D64
processor. The product uses the internal EEPROM to store a number of
4-byte calibration values, generated when the product is calibrated.
I am using the PEMicro's Win32, PROG12Z and ICD12Z programs to
author, program and debug the code, connecting to the BDM via
PEMicro's Multilink USB Multilink interface. The code is written in
assembler.
The EEPROM is mapped to the $0800-0BFF address space by writing $09
to the INITEE register in the startup code. My EEPROM programming sub-
routine uses a sectormodify command followed by a wordprogram command
to store the 4-byte values (which are held in temporary RAM
locations). In a separate routine, I then compare the data in the
EEPROM with the data in RAM to ensure the values have been programmed
correctly. I then calculate a checksum over the entire EEPROM space
and store this as a 4-byte value to address $0BEC.
Now everything works just fine in BDM emulation mode, the data gets
correctly programmed and can be read back from the EEPROM after a
complete power-down/power-up of the whole system. However when I run
the product free-standing, it fails to store the values to EEPROM.
The EEPROM program routine appears to complete fully without errors,
but the data is nowhere to be found in the EEPROM address space.
One odd thing that I did find at the very beginning was that the
EEPROM write addresses increment in 16-bit steps rather than the
usual 8-bit. So it was necessary to include the following code to
adjust the incoming write addresses:
ldd etargetaddr ; incoming write address
subd #$800 ; calculate the sector address
lsrd ; divide by 2
addd #$800
std eaddrhi
I have also noticed when viewing the $0800-0BFF EEPROM data area in
the debug program that it is precisely duplicated at $0C00-0FFF.
Can anyone please offer any suggestions as to why the EEPROM
programming only works in BDM mode?