We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I want to assign absolute address to one of my array. eg. i want to assign the array named as test_ary[] in code memory from 0x1000 location. How can i do it ? unsigned char code test_ary[]={ 0x12, 0x11, 0xFE, 0x22, 0xDE, 0x65, 0x98, 0x22, 0x43, 0x21, ... ... ... }; Here, test_ary is an image of executable code. I want to locate this image i.e test_ary from 0x1000 address in code memory using _at_ keyword. How can i do it ? Thanks in advance.
Last I looked, the tools didn't support using _at_ for this. But you can still use the original method for which _at_ is really just syntactical sugar: put the initialized array into a separate source file, and use linker controls to move it where you need it.
Is this a limitation of Keil that we cant use _at_ for initialized array ? Well, using linker control i can do it. But my problem is that i have a conditional initialization for such array like: #ifdef COND1 //Initialize test_ary from 0x1000 #else //Initialize test_ary from 0x2000 #endif Is it possible to do this with _at_ keyword ?
"Is this a limitation of Keil that we cant use _at_ for initialized array?" Well, let's just take a look at the Manual, shall we? http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm Which part of "Absolute variables cannot be initialized" is unclear?
"Well, using linker control i can do it. But my problem is that i have a conditional initialization" Somewhere, external to your 'C' source, you have to set up that condition, don't you? So, instead of setting it as an option for the Compiler, you just set it as an option for the Linker instead! Maybe you could achieve this in uVision by using two Targets?
Hi Neil, I didnt get you "Maybe you could achieve this in uVision by using two Targets?" Using two targets ?
Read your uVision Manual: A uVision Project may have multiple Targets - you could use this facility?