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.

TMS320F28027: Accessing bit field in registers using .BIT , .all

Part Number: TMS320F28027


Hi,

Im new to coding. Iam having trouble in understanding the style of accessing BIT fields in regsiters using union and structure combined.

struct SCICCR_BITS { // bit description
Uint16 SCICHAR:3; // 2:0 Character length control
Uint16 ADDRIDLE_MODE:1; // 3 ADDR/IDLE Mode control
Uint16 LOOPBKENA:1; // 4 Loop Back enable
Uint16 PARITYENA:1; // 5 Parity enable
Uint16 PARITY:1; // 6 Even or Odd Parity
Uint16 STOPBITS:1; // 7 Number of Stop Bits
Uint16 rsvd1:8; // 15:8 reserved
};


union SCICCR_REG {
                  Uint16 all;
                 struct SCICCR_BITS bit;
       };

In the above code, How exactly particular field(field means particular bit)is written.? How It knows field position(how masking of the other fields in register happens).? My doubt is, Each Field in register defined as Uint16. That means Each field occupies 16bits. If it true, Writing to single filed will occupy full register. 

Kindly help in this.

Thanks