How to define an absolute section with C

cancel
Showing results for 
Search instead for 
Did you mean: 

How to define an absolute section with C

4,734 Views
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
Labels (1)
0 Kudos
3 Replies

91 Views
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 Kudos

91 Views
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 Kudos

91 Views
Contributor I
Found it,I should have initialized it in declaration

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

Anastasios
0 Kudos