Hi,
I'm writing a code and I have a problem with structs and unions.
I read 8 bytes (RXBnD[8]) from an external system, and each of these 8 bytes are structured in 8 bits:
********************************
__saddr union aux_bits2
{
struct
{unsigned char b0:1;
unsigned char b1:1;
unsigned char b2:1;
unsigned char b3:1;
unsigned char b4:1;
unsigned char b5:1;
unsigned char b6:1;
unsigned char b7:1;
};
unsigned char byte;
} RXBnD[8];
***********************************
The problem is that the 'speed' variable is in byte RXBnD[1] and bits 3...0 of byte RXBnD[0]. Other variables are also 'mixed' in various bytes.
So, what I want is to make a union or struct or anything else so that I get the value of 'speed' variable without reading byte RXBnD[1] and bits 3...0 of byte RXBnD[0]. Do you understand me?
Thanks.
I'm writing a code and I have a problem with structs and unions.
I read 8 bytes (RXBnD[8]) from an external system, and each of these 8 bytes are structured in 8 bits:
********************************
__saddr union aux_bits2
{
struct
{unsigned char b0:1;
unsigned char b1:1;
unsigned char b2:1;
unsigned char b3:1;
unsigned char b4:1;
unsigned char b5:1;
unsigned char b6:1;
unsigned char b7:1;
};
unsigned char byte;
} RXBnD[8];
***********************************
The problem is that the 'speed' variable is in byte RXBnD[1] and bits 3...0 of byte RXBnD[0]. Other variables are also 'mixed' in various bytes.
So, what I want is to make a union or struct or anything else so that I get the value of 'speed' variable without reading byte RXBnD[1] and bits 3...0 of byte RXBnD[0]. Do you understand me?
Thanks.