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.

TMS320F28055: Bit feelds.

Part Number: TMS320F28055

Hi.

I want to do my bit fields in my code, like bit field TI.

I do so:
in my Global_Var.c file i write code.

struct StatusSeviceTransmition{
Uint16 Enable_Transmition :1; 
Uint16 ch1_transmit :1; 
Uint16 ch2_transmit :1; 
Uint16 ch3_transmit :1; 
Uint16 ch4_transmit :1; 
Uint16 rsv11 :11;
};


union TransmitionService_REG{
Uint16 all;
struct StatusSeviceTransmition bit;
};

struct Service_REG{
union TransmitionService_REG TransmitionService_REG;
};

struct Service_REG SERVICE_REG;

And so, on in my Global_Var.h file I write next:

struct StatusSeviceTransmition{
Uint16 Enable_Transmition :1;
Uint16 ch1_transmit :1; 
Uint16 ch2_transmit :1; 
Uint16 ch3_transmit :1; 
Uint16 ch4_transmit :1; 
Uint16 rsv11 :11;
};

union TransmitionService_REG{
Uint16 all;
struct StatusSeviceTransmition bit;
};

struct Service_REG{
union TransmitionService_REG TransmitionService_REG;
};

extern struct Service_REG SERVICE_REG;

In main.c file I write: 

SERVICE_REG.TransmitionService_REG.bit.Enable_Transmition = 1;

Code Composer make build and sort of OK. But I'm not sure that my bit field right declared. At first, in my Global_Var.h file, I write extern between struct, like this:

extern struct StatusSeviceTransmition{
Uint16 Enable_Transmition :1;
Uint16 ch1_transmit :1; 
Uint16 ch2_transmit :1; 
Uint16 ch3_transmit :1; 
Uint16 ch4_transmit :1; 
Uint16 rsv11 :11;
};

and builder make this warning: warning #1054-D: a storage class may not be specified here.

Tell me, is I'm correct declared my structure? If not, so how it make right?

  • Hello,

    You only need to define the structs and union in your .h file, and the only thing that needs to be extern in your .h file is the declaration of SERVICE_REG.  The only item you need to put in your .c file is the declaration of SERVICE_REG (without an extern).

    Also, if TransmitionService_REG is the only item you plan on putting in Service_REG, you could skip defining Service_REG and use the union directly. Something like:

    In .h

        extern union TransmitionService_REG SERVICE_REG;

    In .c

        union TransmitionService_REG SERVICE_REG;

    In main.c

        SERVICE_REG.bit.Enable_Transmition = 1;

    It's not necessary, but it's shorter and less to type.

    Whitney