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.

enum CLA



When I define an enum say

typedef enum {

VALUE,

VALUE2,

VALUE3

}myEnum;

With regard to the differences between CPU and CLA where ptrs are 16 vs 32 bits, and ints are treated differently on the two processors, when I use an ENUM across the two processors, is it using an incompatible type across the processors?  I seem to be observing a location mismatch when using enums across the CPU/CLA...

Can I specify that it use unsigned longs for the enums or some compatible type across the processors?

  • Rob,

    enums take on the type int. Since ints are different sizes on the CLA(32-bits) and C28 (16-bits) the cores are going to access them differently. This issue had come up before  

    and we discussed it internally and came up with the following solution at the time. I think it applies now as well,

    "
    In the shared header file, declare
    
    //
    // Globals
    //
    typedef union{
         enum
         {
               Done=0,
               Init,
               Start,
               Rampup,
               Rampdown,
         }enum_t;
         int32_t pad;
    }MOSPROF_State;
    
    
    extern MOSPROF_State state;
    
    on the C28x side, in main() I tried
         state.enum_t = Done;
         state.enum_t = sizeof(MOSPROF_State);
    which gives me
    ;----------------------------------------------------------------------
    ;  68 | state.enum_t = Done;                                                   
    ;----------------------------------------------------------------------
            MOVW      DP,#_state            ; [CPU_U] 
            MOV       @_state,#0            ; [CPU_] |68| 
    ----------------------------------------------------------------------
    ;  69 | state.enum_t = sizeof(MOSPROF_State);                                  
    ;----------------------------------------------------------------------
            MOVB      @_state,#2,UNC        ; [CPU_] |69|
    
    
    On the CLA side, I did something similar
         state.enum_t = Rampup;
         state.enum_t = sizeof(MOSPROF_State);
    which gave me
    ;----------------------------------------------------------------------
    ;  44 | state.enum_t = Rampup;                                                 
    ;----------------------------------------------------------------------
            MMOVIZ    MR0,#0                ; [CPU_] |44| 
            MMOVXI    MR0,#3                ; [CPU_] |44| 
            MMOV32    @_state,MR0           ; [CPU_] |44| 
         .dwpsn     file "C:/Users/a0272561/Repositories/c2000_driverlib/test/f28004x/cla/cla_accessible_functions_unit_test/source/driver_test.cla",line 45,column 2,is_stmt,isa 0
    ;----------------------------------------------------------------------
    ;  45 | state.enum_t = sizeof(MOSPROF_State);                                  
    ;  46 | // Enable the Software Interrupt ability for task 1                    
    ;----------------------------------------------------------------------
            MMOVIZ    MR0,#0                ; [CPU_] |45| 
            MMOVXI    MR0,#2                ; [CPU_] |45| 
            MMOV32    @_state,MR0           ; [CPU_] |45|
    
    In both cases the size of this new enum was 32-bits
    "