About EEPROM security and protection in 9S08

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

About EEPROM security and protection in 9S08

4,293 Views
Sangram
Contributor I
Hello everybody,
 
     Can anybody suggest me any document related to EEPROM paging, security and protection.
What is foreground and background page in 9S08 and how it is useful.
 
 
Thanks in advance
 Sangram
Labels (1)
0 Kudos
12 Replies

876 Views
peg
Senior Contributor IV
Hi Sangram,
 
Which EEPROM are you referring to? Do you mean flash?
I realise that flash memory is technically EEPROM but is normally called flash to differentiate it from older technology EEPROM.
Where did you find the terms "foreground" and "background page" in relation to S08?
 


Message Edited by peg on 2007-08-12 09:26 AM
0 Kudos

876 Views
bigmac
Specialist III
Hello Peg,
 
It is possible that the OP may be referring to one of the newer DN or DZ devices, that have EEPROM in addition to flash.  The sector size for EEPROM is 8 bytes, split between background and forground areas.
 
Further demonstrates the need to be very specific about the MCU type in use.
 
Regards,
Mac
 
0 Kudos

876 Views
Sangram
Contributor I
Hello both,
      Thanks bigmac for mentioning it for me. Yes, I am using 9S08DZ60A uc.
I am really very new in this uc. Specially EEPROM. I want to initialise EEPROM.
So, while reading MC9S08DZ60A datasheet I came accross usch concepts.
   Could you guide me find in detail How to initialise EEPROM and FLASH, program erase.
   What could be the steps one should follow. Any document you will suggest to read.
 
Thanks in advance
 Sangram
0 Kudos

876 Views
peg
Senior Contributor IV
Hi Sangram,
 
I don't know how much you know about other S08's flash but it appears to be the same. They even reference the same core manual for further info. A page seems to have changed to a sector mysteriously without any explanation though. This even further obfuscates the multitude of terms used with these kind of memories. After a quick look the EEPROM works like another array of flash which you could programme from flash presumably. The foreground/background business refers to the way that only half the EEPROM appears in the memory map at any one time. Quite what purpose this serves, especially on the smaller devices, escapes me at the moment. However, I am only reading the datasheet like you can and I may be wrong after only a quick perusal.
My comments here may cause others to check this new device out and offer other opinions though. There are likely few experts on this device here I would imagine.
Reading the HCS08 manual (HCS08RMV1.pdf) may help if you have not done so, although only really for the flash part.
 
HTH
 
0 Kudos

876 Views
Sangram
Contributor I
Yes ,
 I read it but not possible to programm. :smileysad:
 I worked on PIC and Atmel. Now, I am working on migration of code form HC08 to MC9S08DZ60.
So, i have to follow same flow of initialization of EEPROM  configuration.
    Freescale says that HC08 and 9S08 are compatible.. i am not at all agree with this....
 
 Its very painful to follow the philosophy of old uc MC68HC08 for MC9S08DZ60.
  So, i need hints for EEPROM initialisation.. Also, for EEPROM in 9S08DZ they give command list and flow chart for execution of EEPROM command.. Why dont they provide sample code for it...:smileyindifferent:
  I know  I am complaining .. But, i found it  right place for expressing my opinions...
 
Thanks agian in advance
 Sangram
0 Kudos

876 Views
Sangram
Contributor I
Hello everybody,
   Can you help me to make shure that I am thinking in correct way,
I am pasting code for EEPROM byte erase of uc 68HC08AZ60 uc. Which I am suppose to write for MC689S08DZ60. Please, if you have experience on both uc then help me to correct it.
 
/************CODE FOR 68HC08AZ60 ********/
void EEPROM_WRITE(BYTE *ADRESSE, BYTE data)   
{
  DisableInterrupts;
/***********/
      EENVR=0x10;      //EEPORM security disabled
     TEMP_DATA=EEACR;      //Protection register, This register GET loaded with EENVR VALUE after RESET
     TEMP_DATA=TEMP_DATA&0x10; //Protection of all EEPROM blocks disabled
     EEACR=TEMP_DATA;      //send
/************/ 
        /************/ 
 TEMP_DATA=EECR;
 TEMP_DATA=TEMP_DATA&0xEF;     // Select byte erase mode
 TEMP_DATA=TEMP_DATA|0x04;     // EELAT set - Buses configured for EEPROM1 programming or erase operation
 EECR=TEMP_DATA; 
        /************/ 
     
*ADRESSE=DATA;  // Write value to EEPROM
 
   /************/
  EECR=0x0F;    // Set Byte erase mode
  //Set AUTO bit So  EEPGM bit will be cleared automatically after
                // erase cycle terminated.
                // Enable internal charge pump.
 /************/
   /************/
  TEMP_DATA=0xFF;      // wait for EEPGM bit to be cleared
  while(TEMP_DATA!=0x00)
  {Simple wait loop TEMP_DATA=EECR;TEMP_DATA=TEMP_DATA&0x01;}
   /************/ 
         /************/
        TEMP_DATA=TEMP_DATA&0xFE;  // EEPGM clear
 EECR=TEMP_DATA;
 TEMP_DATA=TEMP_DATA&0xFB;  // EELAT delete, attention not together with EEPGM! 
 EECR=TEMP_DATA;
         /************/
        /************/
  EECR=0x07;       // for Pooling and static waiting period paralell
   *ADRESSE=DATA;       // Write value to EEPROM
  EECR=0x07;       // for Pooling and static waiting period paralell
         /************/
 
   /************/
  TEMP_DATA=0xFF;      // wait for EEPGM bit to be cleared
  while(TEMP_DATA!=0x00)
  {Simple wait loop TEMP_DATA=EECR;TEMP_DATA=TEMP_DATA&0x01;}
   /************/ 
 
   /************/
        TEMP_DATA=TEMP_DATA&0xFE;  // EEPGM clear
 EECR=TEMP_DATA;
 TEMP_DATA=TEMP_DATA&0xFB;  // EELAT delete, attention not together with EEPGM! 
 EECR=TEMP_DATA;
         /************/
  
 
 TEMP_DATA=EEACR;  //Protection register
 TEMP_DATA=TEMP_DATA|0x7F; //Protect all EEPROM blocks and EEPROM security disabled
 EEACR=TEMP_DATA; //send
  
  EnableInterrupts;     
 
  return;
}
   
/************CODE FOR MC9S08DZ60 ********/
  
void EEPROM_WRITE(BYTE *ADRESSE, BYTE DATA)   
{
  DisableInterrupts;
   // 1) Clear error flags
   // 2) Write Data value to EEPROM
          *ADRESSE=DATA;
   // 3) FCMD = 0x20 ; Write command code 0x20 for sector erase (As no byte erase mode avlbl)
   // 4) FSTAT_FCBEF = 1; to clear FCBEF AND TO launch command
   // 5) wait for four bus cycle
   // 6) while(FSTAT_FCCF != 1); wait for command to complete
    
  EnableInterrupts;     
 
  return;
}
 
will this code will work for me
Thanks in advance
Sangram
0 Kudos

876 Views
bigmac
Specialist III
Hello Sangram,
 
The HC08AZ60 is more exotic than many other HC08 devices, in that it has two separate flash (and EEPROM) arrays.  This means that your code can be run from one of the arrays whilst the other array is erased and programmed.  This is not the case with most other HC08 devices that have a single flash array.  For these devices, the erase and programming code must be run from either RAM, or from monitor ROM (when applicable).
 
My understanding is that the HCS08, including the DZ60, is in the second category.  So the erase and programming code for flash (and EEPROM) may need to run from RAM.
 
A method that is often used is to transfer the erase or programming routine to the stack, and then run the routine from the stack.  Thes routines are usually directly written in assembly code for compactness.  There should be numerious prior references to this method, including example code, within the forum.  I suggest that you search the forum, perhaps for "doonstack".
 
If my understanding of the DZ60 data sheet is correct, the only difference between flash and EEPROM is the erase sector size.
 
Regards,
Mac
 
0 Kudos

876 Views
peg
Senior Contributor IV
Hi Mac,
 
Did you see something that specifically precludes programming EEPROM from flash. I know it does not mean much but you can mass erase seperately. Perhaps I was just hopeful this was the case.
The manual does not seem to specifically say you can't but it is also missing the now typical warning of "can't programme flash from code running in flash" so it seems to leave the guessing up to the user.
If not then the only benefit of having EEPROM is the smaller minimum erase size and the abiltity to mass erase seperately, hardly seems worth it. Still not sure about this background/ foreground stuff. (I mean why it is done like this)
 
0 Kudos

876 Views
bigmac
Specialist III
Hello Peg,
 
I see you're almost a member of the 1k club!
 
I was also looking for the traditional warning within the DZ data sheet.  I couldn't find it for the QG and AW devices also, but perhaps I didn't look hard enough.  I examined the "Flash memory" section of the data sheets - perhaps the warning may be elsewhere.  However, all data sheets seem to reference the HCS08 Family Reference manual, Volume 1 with respect to in-application programming.
 
Regards,
Mac
0 Kudos

876 Views
Sangram
Contributor I
Hello all,
             I sit seriously infront of my PC to find what is sector errase mode in MC9S08DZ..
 I could'nt find any answer..
   I have routine for old uc 68HC08AZ which has byte errase and program mode.
  In previous source  I was  doing it byte by byte....
  
     Then how to implement it in 9S08DZ..
   Here they are having only sector(4 byte or 8 byte) erase mode..
Can you help me to find out what will happens in sector erase mode.
 
      Suppose I have location L1,L2,L3,L4......
    
LOOP1 
      FIRST I SEND SECTOR ERASE COMMAND
              ERASE L1
 
THEN AGAIN I CALL LOOP1 FOR FOR NEXT ADDRESSES. WILL IT CAUSE ANY PROBLEM FOR PREVIOUS BYTES....
 
      BY THE WAY WHAT IT DO, WHEN I SEND SECTOR ERASE COMMAND.. I MEAN TO SAY WHAT WILL BE THE CONTENTS OF ERASED LOCATION....
   Also, how to enable charge pump associated with flash?
   for EEPROM also is it neccessary to enable charge pump ?
 
Datasheet is unable to answer these questions....
 
Your help is highly appreciated
Sangram
 
   
0 Kudos

876 Views
peg
Senior Contributor IV
Hi Sangram,
 
In leiu of any other info on this I think the best way to proceed is to assume everything is the same for EEPROM as flash and that a sector here is what used to be called a page.
Follow the instructions in the CPU manual referenced before.
The "sector" to be erased is the one you write to just before you load the sector erase command.
Perhaps it may be best to get this working on the flash first as ther is a lot of discussion and examples here on the forum. When you get flash working it should be just a matter of an address change to try it on the EEPROM.
 
0 Kudos

876 Views
bigmac
Specialist III
Hello Sangram,
 
I recall previously reading about the foreground/background EEPROM, but I now can't seem to find the description within the data sheet for the DZ.  What reference are you using?
 
I think that the term "sector" is being used in lieu of "page" - it would seem they have similar meaning.
 
So for EEPROM, you would actually erase the entire sector of say 4 forground bytes, rather than a single byte.  If you were to alter any one of the bytes within the sector, you would need to -
  1. Read the data for the whole sector.
  2. Alter the data byte(s) as required.
  3. Erase the sector.
  4. Program all bytes to the sector.
The erased state of EEPROM bytes should be 0xFF, the same as for flash.  Since the FSTAT and FCMD registers are common to both flash and EEPROM, the erase and program sequence should be identical for both.  The charge pump will be automatically enabled when a command is entered.
 
Regards,
Mac
 
0 Kudos