Reference to this article:
The STM32_KEIL variable specifies the storage area .
STM32H743+Keil-define variables to the specified memory .
Define variables to external storage area
Method 1 Direct definition
char buf[2048]__attribute__((at(0XC0000000)));
Define buf in a continuous area with a starting address of 0xC0000000. This method is simple and efficient, but for a large number of variables, it is troublesome and impractical.
Method 2 Define through linker script
-
1. Modify the linked specimen and define
an area, as shown above (sdram_area). -
2. Define macro definition
#define SDRAM_AREA_ATTRIBUTES __attribute__ ((section("sdram_area")))
- 3. Define variables
char buf[2048]SDRAM_AREA_ATTRIBUTES ;
char buf2[2048]SDRAM_AREA_ATTRIBUTES ;
At this point the variable has been defined to the specified area. Compared with method 1, there is no need to strictly calculate the absolute address yourself, which is more convenient.