I want to pack I/O bits from different ports into one 8bit variable making it easy for putting data on those pins simultaneously is there possibility. The compiler I am using is hitech C. I want to pack( RB2...RB7 , RC2 , RC3) into one 8bit register or variable so that I can use it as an 8bit data port.
thanks for your reply...my requirement is not this rather I want someway like struct or union or something else that may help me pack those I/O bits into one single register...I want to avoid this method you have just told...please guide me if that is possible the method I want
You are still going to have to shift.. even using a union.. If you set up an integer and a bit-field in a union, you still need to get the bits into the right order. What kind of interface are you doing?
The union is a great tool... you can declare an integer (16 bits) and two bytes ( 8 obviously ) and 16 bit_fields.. in one variable .. Very useful for serialization.. The integer and two byte array occupy the same ram space... Quite easily obtained in asm as well.
The union is a great tool... you can declare an integer (16 bits) and two bytes ( 8 obviously ) and 16 bit_fields.. in one variable .. Very useful for serialization.. The integer and two byte array occupy the same ram space... Quite easily obtained in asm as well.
Thanks to both of you seniors.Both of you gave great attention to my problem. On the basis of arguments both of you have given
(also 3v0 said the same thing yesterday when I was on chat) conclusion comes out to be the solution Ian has given and, I am going to use that one. Thank you.
Regards