Brett Wallace

MC9S08DZ60 - EEPROM/Debugging Questions

Discussion created by Brett Wallace on Sep 21, 2007
Latest reply on Sep 26, 2007 by Brett Wallace
I've been trying to program the EEPROM on a MC9S08DZ60 and I have some questions.  I've searched the forums already but I still have some problems/questions.
 
1. I've read some stuff that the EEPROM might not be programmable from flash, does anyone know that this is true?
2. I am using CodeWarrior and using the BDM to debug.  When I am debugging should I see the data location change to the byte that I have written to it? I was assuming that I should have but obvisouly it isn't working yet.
 
Here is the code I am using to try writing to the EEPROM:
void WriteBytetoEEPROM( unsigned int *address, unsigned int data)
{
  DisableInterrupts;              //Disable any interrupts before writing to EEPROM
  if (!FCDIV_DIVLD)
   FCDIV = 0x2D;
 
  if (FSTAT_FACCERR)              //If EEPROM access error flag is set
   FSTAT_FACCERR = 1;             //Then clear it
 
  if (FSTAT_FPVIOL)               //If EEPROM write error flag is set
    FSTAT_FPVIOL = 1;             //Then clear it
  
  while(!FSTAT_FCBEF);
 
  *address = data;                 //Set the data to be written to the address to be written to
  FCMD = 0x20;                    //Write byte to flash
  Pause(4);                       //Wait before clearing FCBEF
  FSTAT = 0x80;                   //Clear command buffer empty flag
  if (FSTAT_FACCERR)              //If EEPROM access error flag is set
   FSTAT_FACCERR = 1;             //Then clear it
 
  if (FSTAT_FPVIOL)               //If EEPROM write error flag is set
    FSTAT_FPVIOL = 1;             //Then clear it
    
  while (!FSTAT_FCBEF);            //Wait for command buffer to be empty
  while (!FSTAT_FCCF);             //Wait for all commands to complete
  EnableInterrupts;               //Enable interrupt again after writing
 
}
 
and this is called in the following way:
    WriteBytetoEEPROM((unsigned int *)EEPROM_BASE,0x1C);
 
EEPROM_BASE is just defined as 0x1400.
 
If anyone could help I would appreciate it, thanks in advance.


--
Alban Edit: Please always include FSL Part Number in Message Subject line.

 


Message Edited by Alban on 2007-09-22 07:55 PM

Outcomes