MC9S12 EEPROM

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

MC9S12 EEPROM

936 Views
GaryOlmstead
Senior Contributor I

I have a project using the MC9S12A64, and would like to use the EEPROM.  Problems: 

There are two very different and contradictory explanations on how it works, one in the processor user guide, and one in the EEPROM user guide. One claims that you write the desired data directly to the desired address, then write to a register to start the write.  The other claims that you write the data to one register, the address to another, then write to a third to start the conversion.  I have tried both ways, neither one is working.

There is no sample code in either CodeWarrior 5.1 or Processor Expert.  CodeWarrior 10.x doesn't support this processor.

I created a sample program that only erases the EEPROM and writes to a few locations.  This code compiles, but won't execute.  The debugger complains that I am accessing unimplemented memory in the form of the EEPROM status register at its default location of 0x0115.

There are no sample programs on either SourceForge or GitHub or any other place I can find.

Despite all of that, I wrote a program that:

    moves the EEPROM to 0x800 and turns it on (INITEE = 0x0b),

   sets the clock speed (14.745MHz divided by 80 = 184kHz),

   erases the array,

   and programs fixed values into the first few locations.

The erasure is working.  The write code hangs up while waiting for the status flag bit CCIF to set.  It never does.  Examining the register set, no status flags are ever set, including BLANK, even though displaying the memory clearly shows it is blank.  This lends credence to the debugger saying it is unimplemented.  If so, where is it?  All the other registers are in their default locations.  (RAM is at 0x1000, EEPROM at 0x800, registers at zero).

So my first question is, has anyone ever gotten this thing to work?  Second question, how?

0 Kudos
2 Replies

648 Views
GaryOlmstead
Senior Contributor I

Ladislav --

Thank you so much for sharing this code.  I was almost convinced that the EEPROM had never worked.  It's good to know that it can be made to function.  Comparing my code to yours, there aren't any obvious differences.  I'll have to go through them both side by side to sort it out.

Thanks again.

Gary Olmstead

Ventura CA

0 Kudos

648 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

I have attached an example project I made 9 years ago. It uses D64 but it is the same as A64 with CAN module.

You can look and compare routines.

Note, never display part of flash or eeprom memory in the debugger memory window when you E/W it because it is not allowed to read part of the memory which is currently E/W. It is enough to move/scroll part of E/W memory from visible part of memory window and then after E/W to move/scroll it back or easier is to check whether correct value was written/ memory was erased by own code.

I also added an answer I provided for flash E/W if you will need to work with the FLASH in the future after this issue......

(there is included description how to set memory map in the debugger to see changes in the memory window of he debugger for flash. Similar for EEPROM)

Best regards,

Ladislav

0 Kudos