uwyciw100 发表于 2017-5-25 14:20:00

指定一组变量的存储位置

请问,如果我想把一组变量(如int a;int c;int b;)在内存中的位置指到一个区域,应该怎么做?有哪位朋友知道,谢谢!!!

Mandelbrot_Set 发表于 2017-5-25 15:04:49

mdk:
#include "absacc.h"
char aaaa __at(0x00012340);

uwyciw100 发表于 2017-5-25 16:17:59

Mandelbrot_Set 发表于 2017-5-25 15:04
mdk:
#include "absacc.h"
char aaaa __at(0x00012340);

谢谢你的答复,单个变量的指定我了解,请问有没有可以指定一组的方法。

Mandelbrot_Set 发表于 2017-5-25 16:37:57

1.数组的话同样
2.可以指定section __attribute__ ((section(_name)))
然后在scatter file指定

uwyciw100 发表于 2017-5-25 16:51:01

Mandelbrot_Set 发表于 2017-5-25 16:37
1.数组的话同样
2.可以指定section __attribute__ ((section(_name)))
然后在scatter file指定


我是想定义多个变量,如:
int a;
int b;
float c;
第二种方法能给个例子吗?十分感谢。

Mandelbrot_Set 发表于 2017-5-25 16:59:44

本帖最后由 Mandelbrot_Set 于 2017-5-25 17:01 编辑

uwyciw100 发表于 2017-5-25 16:51
我是想定义多个变量,如:
int a;
int b;

.c:
volatile int a1 __section("section1") =1221;
volatile int b1 __section("section1") =12;
volatile float c1 __section("section1") =1.2f;

.sct:
RW_IRAM1 0x10000000 UNINIT 0x00001000{; RW data
   .ANY (+RW +ZI)
}
EW_IRAM2 0x10001000 0x00001000{; load address = execution address
          *(section1)
}

map:文件输出
    a1                                       0x10001000   Data         4main.o(section1)
    b1                                       0x10001004   Data         4main.o(section1)
    c1                                       0x10001008   Data         4main.o(section1)

(没用stm的工程,地址不一样...)

uwyciw100 发表于 2017-5-25 17:30:57

Mandelbrot_Set 发表于 2017-5-25 16:59
.c:
volatile int a1 __section("section1") =1221;
volatile int b1 __section("section1") =12;


十分感谢您的答复,谢谢。
页: [1]
查看完整版本: 指定一组变量的存储位置