User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 4 of 33
March 4, 2014
FLASH_API_RX_CFG_DATA_FLASH_BGO
Enables non-blocking data flash operations. When enabled, data
flash operations will occur in the background and API functions
will return before the operation has finished. When disabled API
functions will not return until the data flash operation has
completed.
FLASH_API_RX_CFG_ROM_BGO
Enables non-blocking ROM operations. When enabled, ROM
operations will occur in the background and API functions will
return before the operation has finished. When disabled API
functions will not return until the ROM operation has completed.
FLASH_API_RX_CFG_FLASH_READY_IPL
This is the interrupt priority level that will be used for the flash
ready interrupt when BGO operations are enabled.
FLASH_API_RX_CFG_
IGNORE_LOCK_BITS
If defined then lock bit protection will be ignored. If undefined
then lock bit protection will be used and if a program/erase is
attempted on a block with its lock bit set, the operation will fail.
FLASH_API_RX_CFG_
COPY_CODE_BY_API
After a reset parts of the Flash API must be copied to RAM before
the API can be used. This originally was done by editing the
dbsct.c file to copy the code over when other RAM sections are
initialized. There is now the R_FlashCodeCopy() function which
does the same thing. Uncomment this macro if you will be using
the R_FlashCodeCopy() function. Comment out this macro if you
are using the original dbsct.c method.
Table 1 : Flash API Configuration Items
2.7.1 What About Configuring the MCU Information?
In earlier versions of this API, information about the MCU was required to be input by the user. Examples of
information that was needed included:
Which MCU family (e.g. RX62N)
ROM and Data Flash size
Clock speed supplied to FCU
This is no longer defined in the Flash API middleware since this code now uses the r_bsp package. The r_bsp package
includes startup code and MCU information for different RX boards. The Flash API gets the information it needs from
the files in the r_bsp package. Users are encouraged to add their own boards to the r_bsp package. By having a clear
foundation for middleware to be built on top of this should enable RX middleware to be more easily integrated.
2.7.2 What happened to DATA_FLASH_OPERATION_PIPL AND
ROM_OPERATION_PIPL?
In v2.00 of the Simple Flash API for RX there were two extra #define’s in the user configuration file that are not shown
in the table above. These definitions were removed due to a bug that was found in the code. The way the definitions
were meant to work was that when a flash operation was called, the API would set the MCU’s IPL to a certain level.
When the flash operation was finished, the API would set the IPL back to what it was before the flash operation was
called. Using this method, the user could easily prevent certain interrupts from occurring during flash operation which
could cause a ROM or data flash access violation. The problem occurred when trying to restore the MCU’s IPL at the
end of a flash operation. If the flash operation was done using BGO then it would finish inside of the flash ready ISR.
The IPL could be changed inside of the ISR but since the IPL is restored from the stack when returning from an ISR,
the change essentially had no effect. This means that after the flash operation was finished the MCU’s IPL was not
correctly restored. To fix this, the definitions were removed. This means the user must take extra care to make sure no
interrupts occur during flash operations that may cause an access violation.
If the user would like to restore these features, two options are presented here. The first is to have code that alters the
IPL value that is stored on the stack when an ISR is taken. This can be tricky since the location on the stack can change
depending on how many stack variables are used and how many registers are saved. The other option is to make the
flash ready interrupt the fast interrupt. This option is easier to code for and safer since the IPL will always be stored in