Bitfield for Kinetis

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bitfield for Kinetis

999件の閲覧回数
MAPC
Senior Contributor I

Is there a way to make a bitfield structure for K22 in KDS?

ラベル(1)
0 件の賞賛
返信
2 返答(返信)

813件の閲覧回数
TICS_Fiona
NXP Employee
NXP Employee

Hello Macro

I tested in KDS 3.0 and defined the bitfield structure as below:

union {

       unsigned char bits;

       struct {

                  unsigned char bit0 :     1;

                  unsigned char bit1 :     1;

                  unsigned char bit2 :     1;

                  unsigned char bit3 :     1;

                  unsigned char bit4 :     1;

                  unsigned char bit5 :     1;

                  unsigned char bit6 :     1;

                  unsigned char bit7 :     1;

                }R;

} Test_bit;

And access it in code as:

Test_bit.R.bit7=1;

This works as on other C compiler.

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Mark Correct button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

813件の閲覧回数
egoodii
Senior Contributor III

What are the resulting assembly-level instructions for the C-source 'Test_bit.R.bit7=1;'?  I.e., what is the code-cost for packing density?

0 件の賞賛
返信