User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 21 of 33
March 4, 2014
4.3 R_FlashEraseRange (Not Available on RX610, RX62x)
The function starts erasing data flash blocks at a given address and stops when the number of bytes to
erase has been reached.
Format
uint8_t R_FlashEraseRange(uint32_t start_addr, uint32_t bytes);
Parameters
start_addr
Specifies the address where the erase should begin. This must be on an erase boundary and the
address must be in the data flash area.
bytes
Specifies the number of bytes to erase. This must be a multiple of the data flash erase size. For
example, on the RX630 the data flash erase size is 32 bytes so 32, 64, 96, etc… could used for this
parameter.
Return Values
FLASH_SUCCESS: Operation successful (if BGO is enabled this means the operations was
started successfully)
FLASH_FAILURE: Operation failed.
FLASH_BUSY: Other flash operation in progress, try again later
FLASH_ERROR_BYTES: Number of bytes did not match erase size
FLASH_ERROR_ADDRESS: Invalid address, this is only for data flash
FLASH_ERROR_ALIGNED: Flash address not on erase boundary
FLASH_ERROR_OVERFLOW: Erase attempted to go past end of data flash
Properties
Prototyped in file “r_flash_api_rx_if.h”
Implemented in file “r_flash_api_rx.c
Description
Erases at least 1 data flash block. This function was first introduced for RX63x MCUs that had significantly
smaller data flash erase sectors than previous RX600 MCUs. Instead of having the user deal with a large
number of data flash block #defines, this function allows the user to send in an address and how many bytes
they wish to erase.
Reentrant
No, but is protected by lock to prevent errors from concurrent function calls.
Example
uint8_t ret;
/* Erase 64 bytes. */
ret = R_FlashEraseRange(address, 64);
/* Check for errors. */
if (FLASH_SUCCESS != ret)
{
. . .
}
Special Notes:
This function is not available on RX610 or RX62x MCUs. The reason for this is that these MCUs
have larger data flash erase sectors and therefore can be erased using the R_FlashErase() function.
This function is only available for data flash blocks. Cannot be used on ROM blocks.
Make sure you have enabled modifications of the data flash block by calling the
R_FlashDataAreaAccess() function.