AnsweredAssumed Answered

about PE  FLASH1_Erase method of KEAZ128

Question asked by Jason Zhang on Mar 10, 2016
Latest reply on Mar 15, 2016 by Jason Zhang

Hi,

 

I can't find a function for erase sector in the componet methods, is it right?

 

If I try to erase 0x4000 to (128k-0x4000) memory,

can I do like this of below?

pFlash_Device = FLASH1_Init(NULL);

(void) FLASH1_Erase(pFlash_Device,0x4000,0x1C000);

 

And is there any typical usage for the function of below.

/*

** ===================================================================

**     Method      :  FLASH1_Erase (component FLASH_LDD)

*/

/*!

**     @brief

**         This method sets up a flash memory erase operation. The

**         operation itself is performing by defined batches (property

**         [Erase batch size]) by periodical calling the component抯

**         Main method in the user application (higher level OS service)

**         or by the component抯 ISR, if an component抯 interrupt

**         service is enabled.

**     @param

**         DeviceDataPtr   - Device data structure

**                           pointer returned by [Init] method.

**     @param

**         FromAddress     - Address of the flash

**                           memory area (the first erase sector is the

**                           sector the given address belongs to) to be

**                           erased.

**     @param

**         Size            - Size of the flash memory area (in bytes)

**                           to be erased. The flash memory is erased by

**                           the erase sectors. The first erased sector

**                           is a sector the address specified by the

**                           input parameter Address belongs to. The

**                           last erased sector is a sector the address

**                           calculated like an addition of the address

**                           specified by the input parameter Address

**                           and the size specified by the input

**                           parameter Size belongs to.

**     @return

**                         - Error code

**                           ERR_OK - OK

**                           ERR_DISABLED - Component is disabled

**                           ERR_SPEED - This device does not work in

**                           the active clock configuration

**                           ERR_BUSY - Some flash memory operation is

**                           already in progress

**                           ERR_PARAM_ADDRESS - Desired flash memory

**                           area is out of allowed range or is not

**                           aligned to erasable units' bounderies

**                           ERR_NOTAVAIL - When Safe launch and wait

**                           mode is enabled (property Safe launch and

**                           wait) and safe routine location is defined

**                           in runtime (property Safe routine location)

**                           and the safe routine location has not been

**                           specified yet (the SetSafeRoutineLocation

**                           method has not been used to define the

**                           location the safe routine will be copied to).

*/

/* ===================================================================*/

LDD_TError FLASH1_Erase(LDD_TDeviceData *DeviceDataPtr, LDD_FLASH_TAddress FromAddress, LDD_FLASH_TDataSize Size)

{

  FLASH1_TDeviceDataPtr DevDataPtr = (FLASH1_TDeviceDataPtr)DeviceDataPtr;

  LDD_TError Result;

 

  Result = CheckStateAndRange(DevDataPtr, FromAddress, Size);

  if (Result != ERR_OK) {

    return Result;

  }

  DevDataPtr->CurrentOperation = LDD_FLASH_ERASE;

  DevDataPtr->CurrentOperationStatus = LDD_FLASH_START;

  DevDataPtr->CurrentDataSize = Size;

  /* FTMRE_PDD_CMD_ERASE_FLASH_SECTOR requires sector address to be 4 bytes aligned  */

  DevDataPtr->CurrentFlashAddress = FromAddress & ~(uint32_t)FLASH1_FLASH_WRITABLE_UNIT_MASK;

  FTMRE_PDD_SetCommand(FTMRE_BASE_PTR, FTMRE_PDD_CMD_ERASE_FLASH_SECTOR);

  return ERR_OK;

}

 

Thank you!

 

Jason

Outcomes