EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Problem in using D-Flash for XS128, Need help

Started by yadunandan kasu July 19, 2008
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

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.,.
Global addressing is required for the Data Flash Page erase command.

When you use the local address, the Flash thinks that you
mistakenly wrote to an out of range address, and
sets the ACCERR.
--- In 6..., "yadunandan kasu"
wrote:
>
> 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
>
> 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.,.
>

Yes Mr. Dandre
 
Thank you very very much... I must use the global addresss for Flash command parameters.... After your suggestion, i used the global address in the FCCOB parameters. Now i can erase/program the D-Flash successfully.
 
This is my sample code to erase a D-Flash sector
 
 void Erase_DFlash_Sector(void) 

   if(FSTAT_CCIF == 0)       /* Is any previous command not completed ? */ 
    {
        return;                      /* Break current process */
    }
 
    FSTAT = 0x30;             /* ESTAT: PVIOL=1,ACCERR=1, clear error flags */     
      
   /* Erase sector command sequence */
 
    FCCOBIX   =  0x00;    /* 0th array */
    FCCOBHI  =  0x12;    /* Erase D-Flash Sector command */
    FCCOBLO =  0x10;    /* Global address of D-Flash [22:16] */
   
    FCCOBIX  =  0x01;     /* 0th array */
    FCCOB    =  0x0C00;  /* Global address [15:0] in the sector to be erased */
       
    FSTAT_CCIF = 1;     /* Clear command complete flag to start new command */
   
    if((FSTAT_FPVIOL == 1)||(FSTAT_ACCERR == 1)) /* Is protection violation or acces 
                                                                              error detected ? */
    {
        return;              /* If yes then error */   
    }
    while (!FSTAT_CCIF);
}

 
very thank full for your advise
Nandu
 

          regards
Yadunandan Kasu(Nandu)

--- On Tue, 22/7/08, dandre37 wrote:

From: dandre37
Subject: [68HC12] Re: Problem in using D-Flash for XS128, Need help
To: 6...
Date: Tuesday, 22 July, 2008, 7:27 PM

Global addressing is required for the Data Flash Page erase command.

When you use the local address, the Flash thinks that you
mistakenly wrote to an out of range address, and
sets the ACCERR.

--- In 68HC12@yahoogroups. com, "yadunandan kasu"
wrote:
>
> 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
>
> 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.,.
>



Download prohibited? No problem. CHAT from any browser, without download. Go to http://in.webmessenger.yahoo.com/



The 2024 Embedded Online Conference