yadunandankasu yadunandankasu

Problem in using D-Flash for XS128, Need help

Discussion created by yadunandankasu yadunandankasu on Jul 17, 2008
Latest reply on Jul 24, 2008 by yadunandankasu yadunandankasu
Good day everyone,
 
I am working on MC9S12XS128 MCU.
 
I know that this MCU has the new feature of D-Flash. I am facing a problem in using this and executing its commands on it. I am not very clear about this D-Flash and have the following questions
 
I do not want to use the Global address in my project, so after reviewing the datasheets, i am thinking that a 1Kbyte D-flash is available for XS128 mcu in the local memory map in the range 0x0C00 to 0x0FFF. so, i want to perform program/erase commands in this memory area
 
This is my sample code
 
 
Code:
void Init_Project(void){   /* Init Flash module */  
   FCLKDIV = 0x07;  /* FDIV generates an FCLK frequency of 1.05 MHz */   DFPROT  = 0x10;  /* Disables D-Flash memory protection from program and erase */}void Erase_DFlash_Sector(void){    if(FSTAT_CCIF == 0) /* Is command not completed — */      {        return;         /* Break current process */    }    FSTAT = 48;         /* ESTAT: PVIOL=1,ACCERR=1, clear error flags */            FCCOBIX =  0x00;    FCCOBHI =  0x12;    /* Erase D-Flash sector command */    FCCOBLO =  0x00;    /* Global address = 0 */        FCCOBIX =  0x01;    FCCOB   =  0x0C00;  /* Local D-Flash address, 0x0C00 */        FSTAT_CCIF = 1;     /* Clear command complete flag to start new command */          while(!FSTAT_CCIF); /* wait for command to complete */}void main(void){    Init_Project();    Erase_DFlash_Sector();}  

But after downloading the code and run in the Codewarrior debugger, i can see the memory from
 
0x0800 to 0x0BFF is filled with all " rr rr rr rr rr .... rr"   and
0x0C00 to 0x0FFF is filled with all " -- -- -- -- -- ....--"
 
and i always see the ACCERR bit of FSTAT register is set. that means some acces error.
 
I have the following doubts....
 
1. Do i need to specailly enable the D-Flash and Initialize the D-Flash before running the commands to the memory 0x0C00 to 0x0FFF... (like in case of MC9S12DG128, or D64.. etc.. we will configure the EEPROM with "INITEE" and enable the EEPROM using "MISC")......??
 
2. And am I writing the correct values to the registers FCCOBIX and FCCOB  in my function "Erase_DFlash_Sector()"... ???
 
3. The data sheet mentioned, the FCCOB parameters for this command should contains the Global address [22:16]  to identify D-Flash blocks to be erased... and I dont want to use global memory.. is this creates any problem...
 
Finally, I am confused how to configure the 1KByte D-Flash from 0x0C00 to 0x0FFF and how to run the commands on this memory area.. specially how to write the FCCOB registers if I am not using global memory model..
 
Any kind of suggestions will be greatly helpful to me.,.
 
Nandu

 
 
 
 
 
 

Outcomes