MC9S08DZ60 - EEPROM/Debugging Questions

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

MC9S08DZ60 - EEPROM/Debugging Questions

4,097 Views
allawtterb
Contributor IV
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
Labels (1)
0 Kudos
10 Replies

585 Views
CrasyCat
Specialist III
Hello
 
Which version of CodeWarrior are you using?
To retrieve that info:
    - Start CodeWarrior
    - Select Help -> About Freescale CodeWarrior
    - Click on "Install Products"
    - CodeWarrior version used is displayed on top in the Installed Products dialog.
 
Depending on the version you are using you may need an additional configuration in the debugger.
 
CrasyCat
0 Kudos

585 Views
allawtterb
Contributor IV
The version is 5.9.0, does everything else I am doing look correct as well?
0 Kudos

585 Views
CrasyCat
Specialist III
That does not help a lot.
 
Can you please do the following to retrieve the version number:
    - Start CodeWarrior
    - Select Help -> About Freescale CodeWarrior
    - Click on "Install Products"
    - CodeWarrior version used is displayed on top in the Installed Products dialog.
 
CrasyCat
0 Kudos

585 Views
allawtterb
Contributor IV
Sorry about that, it is V6.0 Release, build 7134-30May07.
0 Kudos

585 Views
allawtterb
Contributor IV
This is getting to be something that might need to be in the Codewarrior forums but I will put it here for now.  I was trying to debug using the BDM, in the "Memory" window of the True-Time Simulator I attempted to do a fill but none of the data changed.  The data locations that were supposed to change turned Red for a but then turned black after the next instruction ran and the data remained the same (0xFF).
 Some extra information, I tried writing an incorrect byte to the FCMD register to see if I could get FACCER to set but it won't set.  From reading the data sheet it seems as though it should set in this case.  Any help would be much appreciated.
0 Kudos

585 Views
allawtterb
Contributor IV
Just to follow up, I was able to get it to show up in the debugger properly just by changing the variable types from int's to chars.
0 Kudos

585 Views
CrasyCat
Specialist III
Hello
 
Thanks for the information on the CodeWarrior version you are using.
 
According to my understanding you are modifying the EEPROM in your application, but the content of the EEPROM remains unchanged in the debugger memory window.
Is that correct?
 
There is a debugging memory map associated with your debug session.
As far as I know the default debugging memory map is defining all FLASH & EEPROM areas as persistent (not changed while application is running.
So if you want to see your memory changing you have to modify the Debugging Memory MAP.
 
This can be done as follows:
  - Start the debugger the usual way
  - Select "MultilinkCyclonePro" -> "Debugging Memory Map"
  - Select the line corresponding to the Memory area where you have your EEPROM
  - Click on "Modify/Details" button
  - Check the "refresh memory when halting" check box
  - Click OK to close the dialog.
  - Click Close to close the second dialog and try debugging again.
 
Content of EEPROM should be refreshed now.
 
CrasyCat
0 Kudos

585 Views
allawtterb
Contributor IV
Actually, the initial problem was I just wasn't sure if the memory map was working correctly. I had tried to manually refreshing by right clicking and selecting refresh in the memory box but the data wasn't changing.  It wasn't changing because it wasn't being written properly by the code posted above. 
 
To make the code work properly I had to change:
 
void WriteBytetoEEPROM( unsigned int *address, unsigned int data)
 
to:
 
void WriteBytetoEEPROM( unsigned char *address, unsigned int data)
 
If I tried to declare data as a char it would not work which was very confusing, because what is being written is just a byte and not a word.  Does anyone know why this is?  Also it wouldn't work if address was an int but that makes more sense.
 
On another note, in the process of this I was trying to write to the EEPROM space using the "fill" command but this was not working, as I said earlier.  The data area that was to be changed would turn red in the memory window but remain 0xFF and after the next instructions would just turn back to black and not change, even when refreshed.  
0 Kudos

585 Views
CrasyCat
Specialist III
Hello
 
As long as the "refresh memory when halting" check box is unchecked for that memory area, the debugger will not physically read the current content of the memory.
 
You need to modify the debugger memory mapping settings as explained in my previous message to make sure the debugger is reading the current values from the memory.
 
CrasyCat
0 Kudos

585 Views
allawtterb
Contributor IV
Before I did that I could still see the memory updated by right clicking and selecting refresh.  I did check that box and I still can't use the fill command to put data in the EEPROM area.  I don't really need to use the function anymore, it was more of an observation.
0 Kudos