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.

C syntax for CCS

Hello,

I am using CCS 3.3.83.19 for the TMS320F38035. I am instancing  the ti CLARKE function as CLARKE clarke1 = CLARKE_DEFAULTS.

clarke1.As and clarke1.Bs are members of this structure

This function works fine, but I am trying to create a table of addresses elsewhere in my code. The code is as follows:

extern _iq clarke1;

const Uint32 TxData[] =

{

(Uint32)&clarke1.As,

(Unint32)&clarke1.Bs

};

I get a compile error : expression must have struct or union type

Can you help me witht the proper syntax to get the address of a member of a structure.?

  • OK

    I have also tried the code below

    extern struct CLARKE clarke1;

    const Uint32 TxData[] =

    {

    (Uint32)&clarke1.As,

    (Unint32)&clarke1.Bs

    };

    Now I get the error: incomplete type is not allowed

    What is the proper syntax to create an array of addresses for structures such as the CLARKE?

  •  

    Once I included the proper header file that contained the definition of CLARKE my below code seems to be working

    extern CLARKE clarke1;

    const Uint32 TxData[] =

    {

    (Uint32)&clarke1.As,

    (Unint32)&clarke1.Bs

    };

  • Hi Gary

    CLARKE it a type defined via typedef and not a structure tag.

    From DMS clarke.h:
    typedef struct {  _iq  As;          // Input: phase-a stator variable
                      _iq  Bs;            // Input: phase-b stator variable
                      _iq  Alpha;        // Output: stationary d-axis stator variable
                      _iq  Beta;        // Output: stationary q-axis stator variable
                        void  (*calc)();    // Pointer to calculation function
                     } CLARKE;

    If within DMS's clarke.h the definition would be like this:
    struct CLARKE {  _iq  As;          // Input: phase-a stator variable
                      _iq  Bs;            // Input: phase-b stator variable
                      _iq  Alpha;        // Output: stationary d-axis stator variable
                      _iq  Beta;        // Output: stationary q-axis stator variable
                        void  (*calc)();    // Pointer to calculation function
                     };

    then your code would work

    You should become more familiar with C syntax for the structures, and type definitions

    Regards, Mitja

  • BTW, you don't want to make an array of addresses by casting pointers to integers.  Your table should instead be something like

      const _iq *TxData[] = { &clarke1.As, &clarke1.Bs };

    In other words, an array of pointers.

    That isn't directly related to your compilation error, but it's an issue that might cause you trouble later.

  • Thanks for the sugestions. Very helpfull.