How to fix the local variables

I hava a need to fix one C file's local variables to some settled address in DATA area, how to do it, thanks very much.

Parents
  • Now, I describe my question again. There are some code segments as follows:

    /* main.c */
    void main ()
    {
    
            //Serial interrupt is open
    
            while (1)
            {
                    schedule_task();
                    Enter_Idle_Mode();
            }
    }
    /* main.c file is end */
    
    /* app.c */
    void cmd_process ()
    {
            int local2;// the local vars are so many also.
    
            // ...
    }
    
    void serial_ISR () interrupt 4
    {
            // 1. Receive Five Bytes APDU command
            cmd_process();// 2. command process
    }
    
    /* app.c file is end */
    
    /* task.c */
    void schedule ()
    {
            int local;// the local vars are many.
            //...
    }
    /* task.c is end */
    


    You will find that when schedule() is running, it will be interrupted by serial interrupt, but I don't want to use reentrant keyword for schedule function, as the reentrant stack isn't efficient.

    So if I define the function schedule in the above code, the Keil will do overlay analysis and maybe the local variables of the schedule() function and app.c file are using the same ram space, and to resolve this question, I give some methods and maybe there will be a better way.

    1. Store the local var of schedule() when entering serial_ISR(), and there is a new qustion that how can I know the local var's address of schedule() function?

    2. Can we fix a block of ram to allocate the local variables of schedule(), and also when the task.c and app.c build, the app.c can reuse the ram that
    allocated by schedule()?

    Can you give some suggestion about the two ways above, or a new idea to give?
    thanks very much.

Reply Children
No data
More questions in this forum