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.

Using Structures, Unions, and Bit fields

Other Parts Discussed in Thread: CSD

I am having a compile problem with the below syntax in IAR. I testing the same block under a regular c compiler and it compiled fine. I am assuming there is some logical error. Please help.

I get the following error: Error[e27]: Entry "CSD" in module main ( C:\Documents and Settings\Robot\Desktop\temp\slaa281b\usage_example_IAR\Debug\Obj\main.r43 ) redefined in module mmc ( C:\Documents and ...)

union {
   
  unsigned char csdBytes[16];
 
  struct{
    unsigned char csdStructure : 2;
    unsigned char reserved1 : 6;
    unsigned char taac : 8;
    unsigned char nsac : 8;
    unsigned char transSpeed : 8;
    unsigned short ccc : 12;
    unsigned char readBlLen : 4;
    unsigned char ReadBlPartial : 1;
    unsigned char WriteBlkMisalign : 1;
    unsigned char ReadBlkMisalign : 1;
    unsigned char dsrImp : 1;
    unsigned char reserved2 : 2;
    unsigned short cSize : 12;
    unsigned char vddRCurrMin : 3;
    unsigned char vddRCurrMax : 3;
    unsigned char vddWCurrMin : 3;
    unsigned char vddWCurrMax : 3;
    unsigned char cSizeMult : 3;
    unsigned char eraseBlkEn : 1;
    unsigned char sectorSize : 7;
    unsigned char wpGrpSize : 7;
    unsigned char wpGrpEnable : 1;
    unsigned char reserved3 : 2;
    unsigned char r2wFactor : 3;
    unsigned char writeBlLen : 4;
    unsigned char WriteBlPartial : 1;
    unsigned char reserved4 : 5;
    unsigned char fileFormatGrp : 1;
    unsigned char copy : 1;
    unsigned char permWriteProtect : 1;
    unsigned char tmpWriteProtect : 1;
    unsigned char fileFormat : 2;
    unsigned char reserved5 : 2;
    unsigned char crc : 7;
    unsigned char reserved6 : 1;                                                                                                             
  } CSD_bit;
} CSD;

**Attention** This is a public forum