User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 22 of 33
March 4, 2014
4.4 R_FlashWrite
This function allows data to be written into flash.
Format
uint8_t R_FlashWrite(uint32_t flash_addr,
uint32_t buffer_addr,
uint16_t bytes);
Parameters
flash_addr
This is a pointer to the Flash or Data Flash area to write. The address must be on a programming line
boundary. See Description below for important restrictions regarding this parameter.
buffer_addr
This is a pointer to the buffer containing the data to write to Flash.
bytes
The number of bytes contained in the buffer_addr buffer. This number must be a multiple of the
programming size for memory area you are writing to. See Special Notes below for important
restrictions regarding 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_ALIGNED: Flash address was not on a programming boundary
FLASH_ERROR_BYTES: Number of bytes provided was not a multiple of the programming size
FLASH_ERROR_ADDRESS: Invalid address was input
FLASH_ERROR_BOUNDARY: (ROM) Cannot write across ROM Area Boundaries
FLASH_ERROR_OVERFLOW: Write attempted to go past end of ROM or DF
Properties
Prototyped in file “r_flash_api_rx_if.h
Implemented in file “r_flash_api_rx.c
Description
Writes data to flash memory.
When performing a write the user must make sure to start the write on a programming boundary and the
number of bytes to write must be a multiple of the programming size. The boundaries and programming
sizes differ depending on what MCU is being used and whether the ROM or data flash is being written to.
Programming boundaries start at the beginning of the flash area and then each boundary is a multiple of the
programming size. For example, if the programming line size is 256, then the flash address you pass must
have bits B0-B7 all be ‘0’.
Some RX MCUs have ROM Area boundaries (different than programming boundaries previously discussed)
that cannot be written over. If the user is writing over this location then they will need to make sure to split up
the writes such that the first write will program up to the boundary, and the second write will start at the
boundary. If the user tries to write over this boundary the function will return an error before doing any
programming operations. The user can see the boundaries for their device by looking at the ROM_AREA_#
definitions for their device in r_flash_api_rx_private.h.
Reentrant
No, but is protected by lock to prevent errors from concurrent function calls.