16 bit in CW

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

16 bit in CW

2,471 Views
ernestsnaith
Contributor I
How do you access only the high and low byte in CW?
 
Cheers
Labels (1)
0 Kudos
3 Replies

337 Views
CrasyCat
Specialist III

Hello

Which processor are you targeting (MPC, Coldfire, HC12, ...)?

What are you trying to do exactly?

Are you trying to access MSByte and LSByte from an address in assembler?
Are you trying to do that in ANSI C?

I need more information to provide an answer.

CrasyCat

0 Kudos

337 Views
rhinoceroshead
Contributor I

Try this:

int a16bitNumber = 0x1122;
char* ptr;
char lowByte, highByte;
ptr = (char*)&a16bitNumber;
highByte = *ptr++;
lowByte = *ptr;

Now highByte will hold 0x11 and lowByte will hold 0x22.

0 Kudos

337 Views
CrasyCat
Specialist III

Hello

I still need to know the processor you are targeting (HC08, HC12, Coldfire, EPPC5xx, .....)

CrasyCat

0 Kudos