How to define an absolute section with C

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to define an absolute section with C

5,677件の閲覧回数
Anastasios
Contributor I
Hello all,

I need to define an absolute data section. How am I going to implement this with c. I tried to declare a global array but it is stored in RAM. I want it to be stored in flash memory.

Thank you all in advance

Anastasios
ラベル(1)
0 件の賞賛
3 返答(返信)

1,034件の閲覧回数
bigmac
Specialist III

Hello Anastasios,

If you just need to store the array data in flash, without concern over the precise location, the following declaration seems to work:

const char string_array1[] = "String1";

Regards,

Mac

 

0 件の賞賛

1,034件の閲覧回数
Anastasios
Contributor I
Thanks Mac and you are right this works.But although I don't mind where it goes in the flash i care that different arrays follow one another in memory. This happens if you declare them one next to the other but arrays have the \0 character in the end so information is not continuous.

I tried to declare a struct

struct Mem_Function{
char point1;
char point2;
char slope1;
char slope2;
};

typedef struct Mem_Function Mem_Func;

I declare o const instance

const Mem_Func foo;

but I don't now how to initialize it,I can't do it in main neither before it(compiler errors).

I think I always can do a trick like declaring continious "const long" variables but I really woud like a C data structure so I can handle it in functions.

Regards,

Anastasios
0 件の賞賛

1,035件の閲覧回数
Anastasios
Contributor I
Found it,I should have initialized it in declaration

const Mem_Func foo={a,b,..};

Anastasios
0 件の賞賛