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

Initialising Values to Structures

Dear Sir,

I am making a program using Keil PK51 package. I am using a structure of arrays declared as:

#define MAX_TESTS 30

struct param{ /* 80 bytes per test */
char mode[MAX_TESTS];
float factor[MAX_TESTS];
int aspVolume[MAX_TESTS];
char temperature[MAX_TESTS];
char filter1[MAX_TESTS];
char filter2[MAX_TESTS];
char unit[MAX_TESTS];
float nvMin[MAX_TESTS];
float nvMax[MAX_TESTS];
char decimal[MAX_TESTS];
int reagVolume[MAX_TESTS];
int sampleVolume[MAX_TESTS];
float linLim[MAX_TESTS];
float blankMin[MAX_TESTS];
float blankMax[MAX_TESTS];
int delayT[MAX_TESTS];
int rateT[MAX_TESTS];
char noOfReadings[MAX_TESTS];
float absMin[MAX_TESTS];
char printCurve[MAX_TESTS];
char shortName[MAX_TESTS][SHORTNAMELENGTH+1];/* +1 is for NULL Character */
char fullName[MAX_TESTS][FULLNAMELENGTH+1];/* +1 is for NULL Character */
float standard[MAX_TESTS];
float blankOD[MAX_TESTS];
float standardOD[MAX_TESTS];
unsigned char DACgainSet[MAX_TESTS][2];
unsigned char calibrationDone[MAX_TESTS];
unsigned char relayStatus[MAX_TESTS][2];

};

struct param xdata saveTestParam _at_ 0x8000;

I want to initialise these 30 tests with some initial values which are different for different tests. One set of structure takes 80 bytes of storage so for 30 tests, 80x30 = 2400 bytes are required.

I would like to store all these values(which are different for different tests) in the code memory and use a for loop to initialise these tests. I am not sure how to store these values in the code memory so that they can be transferred to the structure whenever required.

Can anyone guide me how to do this. I am using a Keil C cross compiler.


Regards,

Mohit

Parents
  • #define MAX_TESTS 30

    typedef struct { /* 80 bytes per test */
    char mode;
    float factor;
    int aspVolume;
    char temperature;
    char filter1;
    char filter2;
    char unit;
    float nvMin;
    float nvMax;
    char decimal;
    int reagVolume;
    int sampleVolume;
    float linLim;
    float blankMin;
    float blankMax;
    int delayT;
    int rateT;
    char noOfReadings;
    float absMin;
    char printCurve;
    char shortName[SHORTNAMELENGTH+1];/* +1 is for NULL Character */
    char fullName[FULLNAMELENGTH+1];/* +1 is for NULL Character */
    float standard;
    float blankOD;
    float standardOD;
    unsigned char DACgainSet[2];
    unsigned char calibrationDone;
    unsigned char relayStatus[2];
    } param;

    param xdata saveTestParam[MAX_TESTS] _at_ 0x8000 =
    {
    // Test 0
    // mod fac asp tem fi1 fi2 uni nMn nMx dec rea sam lin bMn bMx
    0,4.5,...
    // dlT reT noO abs pri sNm fNm sta bla sta DAC cal relay
    0,0,...

    :
    :
    :

    // Test 29
    // mod fac asp tem fi1 fi2 uni nMn nMx dec rea sam lin bMn bMx
    0,4.5,...
    // dlT reT noO abs pri sNm fNm sta bla sta DAC cal relay
    0,0,...
    };

Reply
  • #define MAX_TESTS 30

    typedef struct { /* 80 bytes per test */
    char mode;
    float factor;
    int aspVolume;
    char temperature;
    char filter1;
    char filter2;
    char unit;
    float nvMin;
    float nvMax;
    char decimal;
    int reagVolume;
    int sampleVolume;
    float linLim;
    float blankMin;
    float blankMax;
    int delayT;
    int rateT;
    char noOfReadings;
    float absMin;
    char printCurve;
    char shortName[SHORTNAMELENGTH+1];/* +1 is for NULL Character */
    char fullName[FULLNAMELENGTH+1];/* +1 is for NULL Character */
    float standard;
    float blankOD;
    float standardOD;
    unsigned char DACgainSet[2];
    unsigned char calibrationDone;
    unsigned char relayStatus[2];
    } param;

    param xdata saveTestParam[MAX_TESTS] _at_ 0x8000 =
    {
    // Test 0
    // mod fac asp tem fi1 fi2 uni nMn nMx dec rea sam lin bMn bMx
    0,4.5,...
    // dlT reT noO abs pri sNm fNm sta bla sta DAC cal relay
    0,0,...

    :
    :
    :

    // Test 29
    // mod fac asp tem fi1 fi2 uni nMn nMx dec rea sam lin bMn bMx
    0,4.5,...
    // dlT reT noO abs pri sNm fNm sta bla sta DAC cal relay
    0,0,...
    };

Children
No data