User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 9 of 33
March 4, 2014
3. Add the linker option to map the ROM section (PFRAM) address to RAM section address (RPFRAM) as seen
below.
4. The linker is now setup to correctly allocate the appropriate Flash API code to RAM. Now we need to make sure
that the code gets copied from ROM to RAM after reset. If this is not done before a Flash API function is called
then the MCU will jump to uninitialized RAM. Two ways to copy this code to RAM are presented below.
The first way is to edit the dbsct.c. This file contains an array that specifies which RAM areas need to be initialized
after a reset. In dbsct.c add the initialization of this code for the RAM section as seen below in RED (note: don’t forget
to add the comma on the previous line)
-- FILE [dbsct.c] --
#pragma section $DSEC
static const struct {
_UBYTE *rom_s; /* Initial address on ROM of initialization data section */
_UBYTE *rom_e; /* Final address on ROM of initialization data section */
_UBYTE *ram_s; /* Initial address on RAM of initialization data section */
} DTBL[] = {
{ __sectop("D"), __secend("D"), __sectop("R") } ,
{ __sectop("PFRAM"), __secend("PFRAM"), __sectop("RPFRAM") }
};
Starting with v2.20 of the Simple Flash API for RX, there is now an API function that will copy the code to RAM. This
is the R_FlashCodeCopy() function. Just call this function before making any other Flash API calls. If using this
method the user will need to make sure and uncomment the macro for COPY_CODE_BY_API in
r_flash_api_rx_config.h. If using the dbsct.c method then the user can comment out this macro which will lead to the
R_FlashCodeCopy() function not being compiled.