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

idata

Hello,

Q1: This is a part of my project code flow explanation. I want to allocate seperate memory location in internal data for the formal parameter local variable - lid. How is it possible using Keil options. By default, it is being allocated in the overlaid DATA_GROUP . I cannot use NOOVERLAY, as the runLineTask() routine is too large.

void runLineTask(unsigned char volatile lid)    //this runs forever
{
        unsigned char volatile idata i;

        switch(stateChange[lid])//depending on the change in state, a case is selected
                                // and its related piece of code is executed
        {
                case ON:

                case OFF:

                .       .
                .       .
                .       .

                default: -----
        }

        -----
        -----
        -----
        -----
}

void main(void)
{
        --      //The basic hardware initialization and variables dseclaration
        --      // is done here
        --
        --
        while(1)//this is the loop which runs forever in real-time
        {
                for(i=0;i<NUM_TASKS;i++) //NUM_TASKS = 10
                        runLineTask(i);
        }

        --
        --
        --
}

Q2: What are the overhead problems on the controller if we use idata type for most most frequently used local variables (in while loops) in my project code?

Please advise.

Parents
  • If you want to control the address of the variable, you could pass a pointer parameter.

    void runLineTask(unsigned char volatile idata* lid)
    ...
    
        runLineTask (&i);
    

    Note that the parameter in this case is the
    pointer, and the compiler will place it whereever it wants, not necessarily in idata. Your "lid" will live somewhere in idata.

    Locating information in idata means that you must always access it indirectly, through a pointer in a register. This is somewhat less efficient that direct data access, and somemore more efficient that xdata access. idata is also commonly used for the hardware stack (SP). If you plan to use a lot of it you should be careful about your stack size.

Reply
  • If you want to control the address of the variable, you could pass a pointer parameter.

    void runLineTask(unsigned char volatile idata* lid)
    ...
    
        runLineTask (&i);
    

    Note that the parameter in this case is the
    pointer, and the compiler will place it whereever it wants, not necessarily in idata. Your "lid" will live somewhere in idata.

    Locating information in idata means that you must always access it indirectly, through a pointer in a register. This is somewhat less efficient that direct data access, and somemore more efficient that xdata access. idata is also commonly used for the hardware stack (SP). If you plan to use a lot of it you should be careful about your stack size.

Children
No data