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

Sub classes in NDATA class

Problem:
Is there a way to define groups of variables in different modules and then to force the linker to locate all these in one contiguous memory region. This would be helpful for parameter-variables, which are to be read out from a serial EEPROM. Each module can define its parameter variables, the linker arranges them all together into one contiguous memory area and an other routine can read them all out from the EEPROM in one step.

The RENAMECLASS control seems to be only able to do that for all variables in a module. I'd like to have these feature for individual variables too.

Parents
  • Thank you for your reply. But I had something other in mind (and due to my poor command of the english language was not able to explain it properly). I'd like to have variables from several modules lumped all together in one single memory region. I will try to explain it with an example:
    In a project consisting of many linkable modules there are some global variables the contents of which must be cyclically refreshed from a serial EEPROM. There may be a module named A with some variables defined in them:

    //Module A
    short var1,var2,var3; //some variables
    #pragma PutTheFollowingVariablesIntoClass PARAMETERS
    short pvar4,pvar5;//Parameter-variables
    #pragma BackToStandard
    

    in a second module B there may be
    //Module B
    short var10,var20,var30; //some variables
    #pragma PutTheFollowingVariablesIntoClass PARAMETERS
    short pvar40,pvar50;//Parameter-variables
    #pragma BackToStandard
    

    The linker shall put now the variables pvar4, pvar5,pvar40 and pvar50 into one contiguous memory region so that a third module C may refresh their content like
    //Module C
    //read out from EEPROM to RAM
    Refresh(__Startof("PARAMETERS"),__Endof("PARAMETERS"), ... );
    

    I know of compilers for other microcontrollers which are able to do such things but I found nothing similar in the Keil compiler. Any help how to solve that problem in an other way, is appreciated.

Reply
  • Thank you for your reply. But I had something other in mind (and due to my poor command of the english language was not able to explain it properly). I'd like to have variables from several modules lumped all together in one single memory region. I will try to explain it with an example:
    In a project consisting of many linkable modules there are some global variables the contents of which must be cyclically refreshed from a serial EEPROM. There may be a module named A with some variables defined in them:

    //Module A
    short var1,var2,var3; //some variables
    #pragma PutTheFollowingVariablesIntoClass PARAMETERS
    short pvar4,pvar5;//Parameter-variables
    #pragma BackToStandard
    

    in a second module B there may be
    //Module B
    short var10,var20,var30; //some variables
    #pragma PutTheFollowingVariablesIntoClass PARAMETERS
    short pvar40,pvar50;//Parameter-variables
    #pragma BackToStandard
    

    The linker shall put now the variables pvar4, pvar5,pvar40 and pvar50 into one contiguous memory region so that a third module C may refresh their content like
    //Module C
    //read out from EEPROM to RAM
    Refresh(__Startof("PARAMETERS"),__Endof("PARAMETERS"), ... );
    

    I know of compilers for other microcontrollers which are able to do such things but I found nothing similar in the Keil compiler. Any help how to solve that problem in an other way, is appreciated.

Children
  • I'm not good at English either :)) I got the idea from your first message.
    The reason why I wrote about structures is because struct is a way of putting a set of variables in a contiguous block of memory. On the other hand, it may seem a bit awkward - having to access your global variables via a structure.
    Since it's possible to place all global variables in a module where you want them, why not put all definitions of global variables in that single module? The modules that use those variables would use declarations to make those variables visible to them.

    - Mike

  • Take also a look to the C166 Compiler directives RENAMECLASS and ORDER. These directives are fully documented in the C166 User's Guide, Chapter 2. I think they do exactly what you need.