This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Specific address location for RAM variable in RX140

Hi everybody,

I would like to force some RAM variables to be saved by compiler in spefic address range (for example from 0x100h to 0x200h).

I know it is possible to use

#pragma address

directive, but this means I have to calculate all the address for the variables.

I'm looking a solution like using

#pragma section

directive but I'm struggling how to setup the "C/C++ Build->Settings->Tool Settings->Linker->Section" linker menu in e2studio.

I tried the following test

#pragma section SafetyRAM
uint16_t a = 0x0000U;
uint16_t b = 0xFFFFU;
#pragma section

And I added a section in linker option with name "SafetyRAM" and address 0x100. Compiler gives me a warning:

W0561100:Cannot find "SafetyRAM" specified in option "start"

How can I solve? Thanks




[locked by: Sai (SWF) at 14:18 (GMT 0) on 8 Feb 2023]
Parents
  • here is my solution:

    1. define your section in  "C/C++ Build->Settings->Tool Settings->Linker->Section". in my case 'MYRAM'

    2. add assembler source file to your project. e.g. 'my_asm.src'

    3. define section in assembler code:

        .section    MYRAM, DATA
        .glb        _my_var_1
        .glb        _my_var_2
    _my_var_1:
        .blkl        1
    _my_var_2:
        .blkl        1
        .end

    4. you can access your vars in c-files:

    extern    uint16_t    my_var_1;
    extern    uint16_t    my_var_2;

    void main(void)
    {

        my_var_1 = 100;
        my_var_2 = 200,

    .... and so on....

Reply
  • here is my solution:

    1. define your section in  "C/C++ Build->Settings->Tool Settings->Linker->Section". in my case 'MYRAM'

    2. add assembler source file to your project. e.g. 'my_asm.src'

    3. define section in assembler code:

        .section    MYRAM, DATA
        .glb        _my_var_1
        .glb        _my_var_2
    _my_var_1:
        .blkl        1
    _my_var_2:
        .blkl        1
        .end

    4. you can access your vars in c-files:

    extern    uint16_t    my_var_1;
    extern    uint16_t    my_var_2;

    void main(void)
    {

        my_var_1 = 100;
        my_var_2 = 200,

    .... and so on....

Children