Constant on flash memory

Hello, everyone.

I'm porting a project from IAR to cubesuite+.

The micro is RL78/D1A.

In IAR I can set a constant with a concrete value and put it in a flash mem adress like:
__root const unsigned short variable1        @ 0xB80A = 1234;

In Cubesuit I don't know how to make the same.
I check with the help and documentation and I can't find de documentation about it.

Can somebody help me to implement this


Miquel Soler

  • Hello Miquel,

    Just use the key word __directmap. For details please have a look at the Renesas compiler manual chapter 2.2.5 "Allocating addresses directly".



  • In reply to Fragero:

    Hello Frangero

    Thanks for the answer.

    I know the __directmap parameter, the problem was that I didn't configure correctly the "Memory model type". Now with Large model is working.

    The only problem is define the constant value !!!

    The target is set in flash memory some constant values.

    __directmap const unsigned char test1 = 0xB80A;

    I don't know how to set the value and address at the same time.

    Can you help me with it ?


    Miquel Soler

  • In reply to Miquel_Soler:

    I don't have much experience on CubeSuite+ (=> mostly using IAR EW) , but I don't think that changing the memory model is a good idea.

    This affects all data located in the internal RAM. As a result I assume that code size will increase and performance will decrease.

    You should use type attribute '__far' only for the constant:

    __directmap __far const unsigned char test1 = 0xB80A;

    For the value definition I don't have a solution so far, may be as a workaround you use customer-specific code segment only for 'test1'

    located to the specific address 0x0B80A. But did not check this in a practical example.

  • In reply to Fragero:

    The keyword __directmap seem to be usable only for variables. Please use a customer specific segment located to a fixed address:

       #pragma section @@CNST CC1 AT B80AH

       const unsigned short test1 = 0x1234;

       #pragma section @@CNST @@CNST