T3STY
Full Member level 4
- Joined
- Apr 17, 2012
- Messages
- 239
- Helped
- 24
- Reputation
- 48
- Reaction score
- 24
- Trophy points
- 1,308
- Activity points
- 3,715
With the new LCD Driver I made I'm using an int data type to store 10 bits. Although, I'd like to reduce the size to only 10 bits, the ones I'm really using.
I tried to define a bit field into a struct like this:
But standard C says it will fit into 2 bytes and it will use 2 bytes, even if I'll only be using 10 bits of 16 available.
Smart question: is there any way I can create a 10 bits struct so I won't waste 6 bits?
I tried to define a bit field into a struct like this:
Code:
struct {
unsigned DB0:1;
unsigned DB1:1;
unsigned DB2:1;
unsigned DB3:1;
unsigned DB4:1;
unsigned DB5:1;
unsigned DB6:1;
unsigned DB7:1;
unsigned RW:1;
unsigned RS:1;
} LCD_DATA;
Smart question: is there any way I can create a 10 bits struct so I won't waste 6 bits?