I am coding a sample code for MSP430G2xx on CCS4.
In this sample project , I want to configure the register by bit access.
In my head file , I build a bit access union for each register like below.
When I using it to configure the bit field as this "TACTL.bits.TASSELx = 3 ;",
in fact, "TAIFG" and "TAIE " bit field was changed. - -|||
But, "TACTL.bits.MCx = 2; TACTL.bits.IDx = 2" works well.
Has anybody try "Bit manipulation for 16 bits register" in CCS for MSP430 ?
/******************** source code start ***********************/
union TACTL_16BITS
{
unsigned int u2Reg;
struct
{
unsigned int TAIFG : 1;
unsigned int TAIE : 1;
unsigned int TACLR : 1;
unsigned int _LBIT3 : 1;
unsigned int MCx : 2;
unsigned int IDx : 2;
unsigned int TASSELx : 2;
unsigned int _BITx : 6;
}bits;
};
extern volatile union TACTL_16BITS TACTL;
/********************** source code end ******************************/