Memory intersection problem in IAR Embedded Workbench

64 Views Asked by At

Good day. I'm new to microcontroller programming. I work with ARM Cortex-M4 core, MK12DN512VLK5. The program contains code in assembler and C in IAR Embedded Workbench. The assembler code defines many service variables and writes them to addresses starting at 0x1fff8000. This number is the start of the RAM memory. In C code there is a static array that begins to be written at the address 0x1fff8000. All this leads to overlap of areas and further errors.

Help divide the areas, it is advisable to tell the compiler to start placing the static array from a certain address, e.g. 0x1fff8000+(maximum memory used by assembler). Thanks in advance.

Example of assembler code: my_variable equ 0x1fff8000

Example of C code: static float my_array[100];

1

There are 1 best solutions below

0
Konstantin On

Thanks to the @user694733's comment, it was possible to solve the problem using additional code in the .icf file:

define block ASSEMBLER_CODE with alignment = 8, size = ASSEMBLER_CODE_SIZE {};
place at address mem:0x1fff8000 { block ASSEMBLER_CODE };
keep { block ASSEMBLER_CODE };

Now, the assembler code accesses memory with addresses from 0x1fff8000 to 0x1fff8000 + ASSEMBLER_CODE_SIZE. In this case, the compiler understands that it is impossible to write to this region and starts writing only after the ASSEMBLER_CODE block.