Search code examples
clinkerembeddedstm32iar

IAR define memory region for custom data


I want to define a specific memory region in the STM32 micro where to store some strings. I'm using IAR compiler but I don't find a simple example that can help me to create the region in the correct way using the icf file. How can I create the region and use this region in the code? Thanks


Solution

  • I found this solution:

    In the icf file I define the memory region in this way:

    define region LANGUAGE_region   = mem:[from 0x080FB000 to 0x080FC000];
    "LANGUAGE_PLACE":place at start of LANGUAGE_region  { section .LANGUAGE_PLACE.noinit };
    

    I will fill this region with an external srec file using a programmer. To test the region with a simple program (using an integer) I use this declaration:

    In the header:

    extern const unsigned int mydata @".LANGUAGE_PLACE.noinit";
    

    In the C file:

    const unsigned int mydata;
    

    In the debugger I can see the correct address of mydata constant at 0x0800FB000