Required help in program a word in EEPROM.

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

Required help in program a word in EEPROM.

1,892 Views
admin
Specialist II
Hello,
         I have a query regaring the read/write operation in EEPROM. like i m using Code warrior tool for developing EEPROM driver for S12XDP512 controller. i have try to execute the program for writing one word in EEPROM in Code Warrior's FULL Chip Simulation. But it is giving me an error while running the program. Please help me if anyone has idea,how to simulate the things in Full Chip simulation for Code warrior.
 
CODE:
 /*Test Program to write into the EEPROM.*/
  /*write an appropriate value to ECLKDIV register as per the oscillator freq=4MHz.*/
  ECLKDIV = 0x15;
 
/*Data to write into the Address.*/
  l_ulvalue = 0x55AA;
  /*take the address from the non paged EEPROM for small memeory model default EPAGE is FE.*/
  l_ulEepAdd = 0xFE0D00;
 
   l_ulptr = &l_uladdress;
 
    /*Load the value in ECNFG register.*/
    while(ESTAT_CBEIF == 0x01);
    ESTAT = 0x30;
   /*load the addrress.*/
    l_uladdress = l_ulEepAdd;
     *(l_ulptr) = l_ulvalue;/*write direct value to EEPROM address.*/
     
     ECMD = 0x20;/*load the write sequence command.*/
     ESTAT = 0x80;
     while(ESTAT_CBEIF == 0x00);
     while(ESTAT_CCIF == 0x01);
  
Labels (1)
0 Kudos
3 Replies

344 Views
admin
Specialist II
Hi, Thanks for the information. Yes its not working for the Full Chip Simulation in Code Warrior.
Yes i have board with me of Freescale . When i m trying to flash the code thru code warrior it is asking me to erase the non volatile memory for FLASH and EEPROM.which is done by  debugger.
But if u check the security state of the MCU is unsecured as it is mention in document before doing any operation on EEPROM or FLASH the MCU should be in unsecured state. That is to be checked by the FSEC register in FLASH.
After performing this activity i m flashing my program to program the word in EEPROM as mention below. i have one query regarding the address. Like when u select the small memory model you are able to access only 1k. which is 0x0C00 TO   0x0FFB; and as per the spec of HCS12X512 the default page would be FE.
I have try to gave the logical address as per the code warrior file  .prm but not able to program the word in EEPROM.pls reply if anybody knows.
 
/*local variable to store the data.*/
uint32 l_ulvalue;
/*pointer and variable to store the address.*/
uint32 l_ulEepAdd;
uint32 l_ulptr;
 
/*Code*/
 /*Test Program to write into the EEPROM.*/
  /*write an appropriate value to ECLKDIV register as per the MCU bus clock is 2MHz..*/
  ECLKDIV = 0x15;
 
  l_ulvalue = 0x55AA;
  /*take the address from the non paged EEPROM for small memeory model.*/
  l_ulEepAdd = 0x0D00;
  l_ulptr = &l_uladdress;
 
   if(ESTAT_CBEIF == 0x01)
   {
      *l_ulptr = l_ulvalue;
     
      ECMD = 0x20;
     
      ESTAT = 0x80;
   
     if((ESTAT_ACCERR|ESTAT_PVIOL) !=0)
     {
        /*fail.*/
     }
     while(ESTAT_CCIF != 0x01);
   }
   else
   {
       /*fail.*/
   }
  
0 Kudos

344 Views
admin
Specialist II
Hi, on how many I know pages it is possible to switch change of value of register EPAGE.
0 Kudos

344 Views
kef
Specialist I
As far as I know, full chip simulator doesn't simulate EEPROM. Check the docs what's simulated and what not.
0 Kudos