Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Data type - new data type nibble

Status
Not open for further replies.

AlGeorge

Member level 1
Joined
Nov 17, 2009
Messages
39
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Waihi Beach
Activity points
1,606
Data type - nibble

Hi due to limited PIC resources, I need to access nibble of the char data. Values do not exceed 15. Instead of continually shifting the bits can I define a new data type nibble? If so, can anyone suggest how. I'm using cc5x compiler.
Thanks,
Alistair.
 

Data type - nibble

I think you can define a struct like this:
typedef struct
{
char data1:4;
char data2:4;
}nibble;
 

Re: Data type - nibble

unaided said:
I think you can define a struct like this:
typedef struct
{
char data1:4;
char data2:4;
}nibble;
Thanks compiler does not like eg
typedef struct {char parthours:4;}nibble;
^------
Error[1] C:\PICdev\myjob.c 50 : Not implemented
(The syntax is not implemented. This can be a compiler limitation)

typedef unsigned int data1:4;
^------
Error[1] C:\PICdev\myjob.c 50 : Not implemented
(The syntax is not implemented. This can be a compiler limitation)
 

Data type - nibble

$0.02 suggestion. Your could use macros: get_upper_nibble(...), get_lower_nibble(...), set_upper_nibble(...), set_lower_nibble(...). This wouldn't help you declare the data type, but it could streamline your code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top