I'm using an 8051 like controller.
In the past I worked with an other micro and his compiler and I was able to reserve a memory zone to place my "not to be initiated" variables.
With the old compiler I could use the following lines in my code:
#pragma memory=dataseg( NOINIT ) unsigned char dummy; #pragma memory=default
to place the variable dummy into the segment NOINIT. Then in the linker control file I could define the segment NOINIT in a chosen memory zone and then in the cstartup I could not initiate that memory zone. In this way I could choose to place variables in two different memory zone and have them zeroed at every reset or not.
Searching in the manual I found the keyword _at_, but it's slight different because in my example I didn't have to care about placing my NOINIT varibles, it was the linker who did it, while with the _at_ keyword I have to care for every variable and be careful not to overlap to an existing one. Is there a way to do what I need with C51 V7.50 and BL51 V5.12? Thanks in advance.
Quote: "Then you can use either the linker, or the _at_ keyword, to put variables into that area."
I just have no idea on how can I use the linker to put variable in that area... Can you point me to the right direction? Thanks.
dead easy in assembler have your XDATA in an assembler module and make a .h that has them as extern for your C
Erik
example assembler for 8k RAM. You also need to modify startup.a51 to exclude the clearing
PUBLIC ..... ?XD?mcxdata SEGMENT XDATA RSEG ?XD?mcxdata firstone: ds 0 ....: ds ... lastone: ds 0 ;; these 16 bytes are not cleared by startup @@@@@@@@@@@@@@@ ds (01ff0h -(lastone - firstone)) ......: ds 1 end
"I just have no idea on how can I use the linker to put variable in that area... Can you point me to the right direction?"
To the Linker Manual? - of course I can:
http://www.keil.com/support/man_c51.htm
http://www.keil.com/support/man/docs/c51/c51_userclass.htm
http://www.keil.com/support/man/docs/lx51/lx51_classes.htm