User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 16 of 33
March 4, 2014
3.6 Interrupts
ROM or data flash areas cannot be accessed while a flash operation is on-going for that particular memory area. This
means that care will need to be taken when allowing interrupts to occur during flash operations. These precautions
apply whether the user is using BGO operations or not.
3.7 Configure for Only Data Flash Use
The Flash API can be configured to only enable data flash operations. This can be very beneficial for users who do not
need ROM operations because it saves code and RAM space. If ROM operations are disabled then the user does not
need to have any of the Flash API code in RAM. This means the user does not need to setup the RPFRAM and PFRAM
sections. In order to disable ROM operations the user should do the following:
1. Comment out the FLASH_API_RX_CFG_ENABLE_ROM_PROGRAMMING macro in the file
r_flash_api_rx_config.h.
2. If you previously setup the RPFRAM and PFRAM sections then you can remove them. You can also remove the
ROM to RAM mapping that was previously setup. See Section 2.13 for more info.
3. You do not need to call the R_FlashCodeCopy() function if ROM operations are disabled. If you do call it, it will
just return without doing anything.
3.8 Erase Entire User Application Area (ROM)
There are multiple ways to erase the entire User Application Area. One way is to place the Flash API in the User Boot
Area. This area is usually used for bootloaders and can only be erased in Serial Boot Mode. Since the user’s application
cannot run in Boot Mode, the user does not have to worry about accidentally erasing the User Boot Area. When using
the User Boot Area the user will still need follow the steps to copy the appropriate Flash API functions to RAM. The
user will also need to move the relocatable vector table to either the User Boot Area or RAM if they are using ROM or
data flash BGO.
Another way to approach this is to copy everything to RAM and use RAM exclusively. When doing this the user will
need to modify the Flash API code to put the array that holds flash addresses in RAM instead of ROM. Follow these
steps to move the array to RAM:
1. Open up the header file for your MCU’s Group in the src/targets/ folder. For example, if you are using the RX62N
MCU then you would open the file src/targets/rx62n/r_flash_api_rx62n.h.
2. In the file find the g_flash_BlockAddresses[] array. There will be two declarations of the array. One that actually
defines the array’s contents and the other that declares it as an extern. Remove the const keyword from both
declarations. Removing the const keyword will move the array to RAM.
If using RAM only the user will also need to move the relocatable vector table to RAM if they are using ROM or data
flash BGO since these features use FCU interrupts.
3.9 Reading from Data Flash After Reset
After reset the user cannot read, write, or erase the data flash. In order to enable these operations the user will need to
call the R_FlashDataAreaAccess() function. See the API information page (Section 4.5) for more information.
3.10 Checking if a Data Flash Location is Blank (Erased)
Data flash locations on the RX cannot be checked for blank (i.e. erased) by comparing the read value to 0xFF. The
reason for this is that RX data flash cells actually have 2 cells per bit (compared to 1 cell per bit for ROM). This means
that there are 4 different states the bit can be in; though only 3 are used: undefined, 0, and 1. Erased data flash locations
on the RX have a value of undefined (not 0 or 1) and therefore the read bit value cannot be used to determine if the bit
is erased. When a data flash bit is programmed, one of the cells is always changed depending on whether a 0 or 1 is
being written. If the user wishes to know if a data flash location is erased then they should use the
R_FlashDataAreaBlankCheck() function (Section 4.6). This API function uses the Blank Check feature of the RX’s
Flash Control Unit (FCU) to determine if a data flash location has programmed data or not.