AnsweredAssumed Answered

Problem with erase and write flash in S12

Question asked by mojtaba bargozide on Dec 20, 2019
Latest reply on Dec 28, 2019 by mojtaba bargozide

Hi guys,

I have a Bootloader and application files in project with part of S912G128MLL,now i cant erase and write flash with Bootloader.

 this is my app .prm file:

**************************************************************************************

NAMES END

HEXFILE bootloader.s19

SEGMENTS

      RAM           = READ_WRITE    0x2000 TO   0x37ff;

      DFLASH        = READ_WRITE   0x000400 TO 0x0013FF; 

      ROM_1400      = READ_ONLY     0x1400 TO   0x1FFF;

      ROM_4000      = READ_ONLY     0x4000 TO   0x7F7F;                 

      ROM_C000      = READ_ONLY     0xC000 TO   0xEFDF;

     

      PAGE_08       = READ_ONLY   0x088000 TO 0x08BFFF;

      PAGE_09       = READ_ONLY   0x098000 TO 0x09BFFF;

      PAGE_0A       = READ_ONLY   0x0A8000 TO 0x0ABFFF;

      PAGE_0B       = READ_ONLY   0x0B8000 TO 0x0BBFFF;

      PAGE_0C       = READ_ONLY   0x0C8000 TO 0x0C93FF;

      PAGE_0C_A000  = READ_ONLY   0x0CA000 TO 0x0CBFFF;

      PAGE_0E       = READ_ONLY   0x0E8000 TO 0x0EBFFF;   

END 

PLACEMENT

      _PRESTART,         

      STARTUP,              

      ROM_VAR,              

      STRINGS,            

      VIRTUAL_TABLE_SEGMENT,

      NON_BANKED,           

      COPY                                                                            

                        INTO  ROM_C000;                    

      DEFAULT_ROM       INTO  PAGE_08, PAGE_09, PAGE_0A, PAGE_0B, PAGE_0C, PAGE_0C_A000, PAGE_0E ;

      SSTACK,                

    DEFAULT_RAM         INTO  RAM;

END

ENTRIES 

END

STACKSIZE 0x100

*****************************************************************************

 this is my Bootloader  .prm file:

*****************************************************************************

INIT _BootStart

NAMES END

SEGMENTS          

      RAM           = READ_WRITE    0x3800 TO   0x3CFF;     

      RAM_CODE_SEG  = READ_ONLY     0xFD00 TO   0xFEFF RELOCATE_TO 0x3D00;     

      ROM_F000      = READ_ONLY     0xF000 TO   0xFCFF;

END

PLACEMENT

      ROM_VAR, 

      STRINGS, 

      DEFAULT_ROM,

      NON_BANKED      INTO  ROM_F000;

      DEFAULT_RAM     INTO  RAM;

      RAM_CODE        INTO  RAM_CODE_SEG;

END

ENTRIES

  flash_array

END

STACKSIZE 0x100

VECTOR 0 _BootStart

VECTOR 1 _BootStart

VECTOR 2 _BootStart

*************************************************************************************************************

and this is my erase code in bootloader :

************************************************************************************************************

UINT8 PFlash_EraseSector(UINT32 address)

{

  while((FSTAT & FSTAT_CCIF_MASK) == 0); 

  FSTAT = 0x30;   

  FCCOBIX = 0x00;

  FCCOB = 0x0A00 | ((address & 0x00080000)>>16);

  FCCOBIX = 0x01;

  FCCOB = (address & 0x0000FFF8);

  FSTAT = 0x80; 

  while((FSTAT & FSTAT_CCIF_MASK) == 0);

  if((FSTAT & (FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK)) != 0)

   return FlashEraseError;

  else

   return noErr;

}

/******************************************************************************/ 

UINT8 PFlash_EraseSectorBySector(UINT32 addr_l, UINT32 addr_h)  // addr_l=0x088000 , addr_h=0x08EFDF

{

  UINT32 Address;

  UINT8 Error;   

  for(Address = addr_l; Address < addr_h; Address += FLASH_SECTOR_SIZE)  // FLASH_SECTOR_SIZE=200

  {

    Error = PFlash_EraseSector(Address);

    if(Error != noErr)

      return(Error);

  }

   return(noErr);

}

here is main code location

.

.

.

 

Please tell me where is my wrong

TNX

Outcomes