Hello Everyone,
This question is very basic.
I would like to know the syntax for accessing individual bits .
For example Consider this register
I2C0_C1
I would like to access the MST bit in this register.I'm not sure how to code it in code warrior.
For example in microchip's MPLAB IDE it is done like this:
I2C0_C1bits.MST = 1; //start command
Is there any equivalent syntax in freescale cw?
I know i can OR a value to the I2C0_C1 register like this
I2C0_C1 |= I2C_C1_MST_MASK; |
,but that is another alternative.
Thanks in advance,
AK
Hello Ak,
On CW, it only can us the method you mentioned "I2C0_C1 |= I2C_C1_MST_MASK;" ,
we can see that , in the header file "MK60D10.h" , it have not define the bits of the I2C_C1 register.
And why you need use the method of "I2C0_C1bits.MST = 1;"? If it must be us the method ,you can copy the difine to the header file .
Have a great day,
Alice
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Alice,
Thanks for the reply.Yes i figured as much.
Its not a big issue but if there was any implementation of accessing the individual bits ,it would be very help,for example i could directly return the status with a single call like this:
int myfuction()
{
//data
return I2C0_C1bits.MST;
}
Oh Arun,
I think you can only define the bits on header file by yourself .
BR
Alice