This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

fields in struct not updating

I've typedef a struct. I've got a local variable defined of this struct. when I assign values to the fields, I do not see the values change in the expressions window. If I define the variable outside of the function, I see the values change. I don't seem to have this issue with other sturcts I've defined. what's going on?

  • Can you post the code so we can see what else is going on? Are you trying to see the values while executing? The debugger handles local variables differently from global variables. You have to be in the function and have execution paused to get the values to show.

  • if I make the local arrays size 1, then I can see the values change in the expressions window. I think that maybe a linker issue?

    typedef struct {

    unsigned char utcYear;

    unsigned char utcMonth;

    unsigned char utcDay;

    unsigned char utcHour;

    unsigned char utcMinute;

    unsigned char utcSecond;

    unsigned short flightLeg;

    unsigned char flightPhase;

    char faultId;

    unsigned short faultCount;

    unsigned char cm_005[8];

    unsigned char cm_009[8];

    unsigned char cm_007[8];

    } *PFAULT_RECORD_T, FAULT_RECORD_T;

     

    FAULT_RECORD_T structFaultRecord;

    FAULT_RECORD_T structReadFaultRecord[200];

    unsigned short usCumulativeCount[128];

    Uint16 u16Count;

    Uint16 u16Pointer;

    int i;

    structFaultRecord.utcYear = 1;

    structFaultRecord.utcMonth = 2;

    structFaultRecord.utcDay = 3;

    structFaultRecord.utcHour = 4;

    structFaultRecord.utcMinute = 5;

    structFaultRecord.utcSecond = 6;

    structFaultRecord.flightLeg = 7;

    structFaultRecord.faultId = 8;

    structFaultRecord.faultCount = 9;

    structFaultRecord.flightPhase = 10;

    structFaultRecord.faultCount = 11;

     

  • Did you allocate enough space for the stack in your linker command file? If those arrays are declared as local variables, your stack will need to be at least 7k words to hold them all.

    If your linker command file is correct, you could also try setting the stack size in the build options. It's under C2000 Linker -> Basic Options -> Set C system stack size.