Variable on 0x1000 0010 address

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Variable on 0x1000 0010 address

1,487 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Albert on Fri Feb 11 10:58:32 MST 2011
Hi, someone know how to save a variable or matriz on specific address?

I need to save the value the variable cont on the address 0x1000 0010, someone can post one example.

Thanks.
0 项奖励
回复
4 回复数

1,440 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Albert on Fri Feb 11 19:12:27 MST 2011
Hi jharwood,
I decided to create a new section by editing the files .ld.
In the program,  I used the __attribute__ ((section("name"))) on the declaration, see:

__attribute__ ((section(".Matriz"))) volatile unsigned char M[32];
void main ( )
{
...
}

Now works fine.

Thanks for the help.
0 项奖励
回复

1,440 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Fri Feb 11 13:31:59 MST 2011
Take a look at your project's .map file to see how the linker has allocated the .data and .bss sections. Then you have to consider how far down from the top of ram the stack may grow and avoid that area.

I would strongly advise against doing things behind the compiler's back, though.

Tried a quick and dirty test and verified with the debugger that it was working. How are you testing yours when you say 'it doesn't work'.
0 项奖励
回复

1,440 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Albert on Fri Feb 11 12:37:33 MST 2011
How can I see If the linker that already allocated that area of SRAM for global data?
I intend to save some data on specific place on SRAM (0x10000000 - 0x10008000) and use the MPU for protect this area. Its possíble?

I need to create a global variables on specific area, this is my subject.

I tried the code below, but it doesn't work:

    volatile unsigned int *p = (unsigned int *)0x10000300;
main( )

  *p = 0x33;
...
}

Do you know why?

Thanks
0 项奖励
回复

1,440 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Fri Feb 11 12:19:34 MST 2011
Are you absolutely certain that the compiler hasn't already allocated that area of SRAM for global data? It would be interesting to know why you need to poke data into a specific location.

But ....

    my_var_type *p = (my_var_type *)0x10000010;
    *p = my_var;

0 项奖励
回复