EEPROM PROGRAMING in MC9S12XDP512 / XA512

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

EEPROM PROGRAMING in MC9S12XDP512 / XA512

3,369 Views
Karan
Contributor I
I am trying to write to the EEPROM with the following code:

word EEvar1@0x0C00;    // Global Varriable Declared at unpaged EEPROM location
main()
{
        ECLKDIV = 0x49;
  
    while(!ESTAT_CBEIF);
   
    if(ESTAT_PVIOL == SET && ESTAT_ACCERR == SET)
    {
        ESTAT = 0x30;
    }
   
        EPROT_EPOPEN = SET;
       
        EEVar1 = 0x9876;
       
        ECMD = 0x20;
       
        ESTAT_CBEIF = SET;
       
       
        while(!ESTAT_CBEIF);
       
        while(!ESTAT_CCIF);
}

The EEPROM seems untouched after the execution. The processor has a 16Mhz Osc clk input and 8Mhz Bus speed. The only time anything gets written to the EEPROM is when I initialize the variable with some value (compile time). Any help would be greatly appriciated.
Thanks

PS : The processor is running in Normal Expanded mode
Labels (1)
0 Kudos
8 Replies

576 Views
admin
Specialist II
Good afternoon, Karan. I use MC9S12XDP512, and have faced the same problem: I can not write down anything in EEPROM. If you have solved the given problem could not prompt to me as.............. Thanks for the help, I look forward to hearing with impatience))))))
0 Kudos

576 Views
Karan
Contributor I
Hello KoT. I figured out the problem and its a rather silly one. It seems that the Hi-Wave debugger has a bug it it. The EEPROM gets written but does not get updated in the debugger, not in the "Memory" window nor in the "Data" window. Only way to refresh it is to double click on each of the location in the "Memory" window and then it gets updated everywhere ("Memory" and "Data"). Hope this helps
0 Kudos

576 Views
admin
Specialist II
Hello Karan. Has decided to check up that you have advised in previous the message. I use a code example laid out by you above, there is an error "Link Erorr: L1100: Segments EEPROM (0xC00) and.absSeg655 (0xC00) overlap". You turn out changed a memory allocation in a file *.prm. You can not prompt as it correctly to make?
0 Kudos

576 Views
Karan
Contributor I
Hey KoT. In that example, EEvar1 is being used as an absolute variable using the global variable address modifier (@). The condition of using this modifier is that, the address you are tyring to hardwire it to, should not be used in any of the sections in the prm file. If you open your project prm file, under the SEGMENTS, you would see something like :

EEPROM = READ_ONLY 0x0C00 TO 0x0FFF;

The address 0xC00-0xC01 is being used by both EEvar1 and EEPROM segment.Thats why you are getting the error.

Change this to 0xC02 TO 0x0FFF and the error should disappear.
0 Kudos

576 Views
admin
Specialist II
Whether it turns out that EEvar1 in an example would be used what to check up for this purpose only the data in EEPROM, whether so it has registered?
0 Kudos

576 Views
Karan
Contributor I
???, did'nt understand your question
0 Kudos

576 Views
admin
Specialist II
Hello Karan, on the score of last question do not get into the head, thanks you for the help I with all have understood, is very grateful for your answers;-)
0 Kudos

576 Views
Karan
Contributor I
anytime, :smileyhappy:
0 Kudos