Karan Soin

EEPROM PROGRAMING in MC9S12XDP512 / XA512

Discussion created by Karan Soin on Oct 23, 2007
Latest reply on Oct 10, 2008 by Karan Soin
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

Outcomes