This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to store a variable in a particular memory location

we are designing DATA loggers for Railways. For that we are using 2468 ARM processor. while designing the system we have an issue that

all local variables should be stored in INTERNAL RAM (64k) & all GLOBAL VARIABLES
should be stored in EXTERNAL SDRAM.

is this feature available in KEIL ARM if so how to configure it.

Another one is how to STORE a variable in a particular memory location (global or local variable) in Keil compiler..

can any one help me.........

Parents
  • Replay to Are you sure that this is the best (or even a good) way to proceed?
    ik

    Data logger is a very big project, every day it has to log 1lak packets. For this memory managemet is the big issue for us. so we are accessing the EXTERNAL memories also (SDRAMs).we have variuos modules for that we have various buffers common to all modules which are very big in size. so these buffers should be global to the system. internally we have very less memory. So our idea is to make the internal memory for the creation of local variables & external SDRAM memory for global variables creation.

    will u suggest any approach......if possible

Reply
  • Replay to Are you sure that this is the best (or even a good) way to proceed?
    ik

    Data logger is a very big project, every day it has to log 1lak packets. For this memory managemet is the big issue for us. so we are accessing the EXTERNAL memories also (SDRAMs).we have variuos modules for that we have various buffers common to all modules which are very big in size. so these buffers should be global to the system. internally we have very less memory. So our idea is to make the internal memory for the creation of local variables & external SDRAM memory for global variables creation.

    will u suggest any approach......if possible

Children
  • "all local variables should be stored in INTERNAL RAM (64k) & all GLOBAL VARIABLES
    should be stored in EXTERNAL SDRAM."

    Normally, local variables would be stored on the stack, and global variables elsewhere.

    So you could locate the stack in internal RAM and ensure other variables are stored elsewhere.

  • "Data logger is a very big project"

    The Keil tools are used to dealing with large projects - it is far better to leave the tools to manage this stuff than to try to "fight" them.

    Unless you have some specific problem with the way that the tools allocate memory, I would strongly recommend that you do not interfere!

    If you find that you really do need to take manual control, then the Linker Scatter Loading File (or just "Scatter File" for short) is the means by which to do it.
    See the Linker manuals for details.

    NB: it's "reply" rather than "replay"

  • Is it possible to know the address of the variable whose location is choosen by the keil compiler???( is keil support any predefined instructions??).....

    one way to choose the particular address

    int var __attribute__((at(0xA0001000))); var=0x28;

    but everytime it is difficult to choose the diff address for diff varible.( some times same address may be mistakenly allotted to other variables where keil compiler will not generate any error).

    if we allow the compiler it will takes the burden. but now if the compiler allots the memory we don't know where the location is...?
    is it possible to get the address of the variable with any type of instructions..??? is keil support this feature..???

  • Thanque Andy Neil.. It seems linker manual will provide some valid information. I hope i will get the solution to my problem..

  • This information is provided in the Linker listing or "Map" file - again, see the Manuals for details!

  • but everytime it is difficult to choose the diff address for diff varible.

    Which brings us right back to the original issue: Why do you believe you have to muck with that in the first place? The compiler and linker are quite perfectly capable of getting variable location right entirely without your "help". So why interfere with it?

  • In fact, all of the toolset manuals!

    You said yourself this is not a trivial project - so you need to be properly prepared by making a thorough study of the necessary documentation!

  • The compiler and linker are quite perfectly capable of getting variable location right entirely without your "help".

    Yes. I always trusted the tools. Until they decided to put things in places that wasn't right for my hardware configuration.

    Truth is: the tools know about 'typical' hardware configurations. If you have something non-typical, then you can give the tools a little hint (or maybe, sometimes, a big kick).

    But before you do, you need to understand the details of what the tools do, what could be manipulated and how.

  • The problem is i'm new to this job (project). I have no idea about this project. from last 10 years our company supplying data loggers to Indian Railways. now we want to release the new verson Data loggers. i don't know exactly my role in this project. my manager assigning me some small tasks like the queries previously i asked .thats way i am not giving clarity while asking the questions. once again thanque Ande Neil for ur valuable suggessions.

  • "i'm new to this job (project)"

    Do you have any prior experience with embedded microcontroller development?

    "I have no idea about this project ... i don't know exactly my role in this project"

    You urgently need to get these things clarified with your management!

    "my manager assigning me some small tasks like the queries previously i asked"

    You really need to ensure that you understand your assigned tasks!

  • i have no prior experience in embedded controllers.

  • It's possible to move special variables to a separate source file and have the linker place them in a separate memory segment.

    Or just access large log variables in separate segment using pointers - basiaclly just statically allocate the memory as one or more arrays of something. This works well if it's a question of storing scratch or log data separately.

  • Yes, of course it is possible - but is it a good idea?

    If the OP can't give any reason(s) for doing this - let alone any good reasons - how can he tell whether any suggestions received here are actually appropriate to the requirement?

  • The only really good reason is to dedicate a fixed memory region as protected without zero-init.

    And it is also possible to update firmware without losing the logged data.

    But obviously, special memory regions are special for a reason - to solve a special problem. If the OP doesn't know he has a special problem, then he probably don't need to allocate some variables to a special memory region.

    Special solutions should never be used without any special problems to solve. And many special problems can be rewritten to fit non-special solutions.