LSB and MSB

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

LSB and MSB

Post by Lord Grezington »

Hey

I recently picked up a project where I need to use the I2C. However my value required is stored on two separate registers (MSB and LSB). The questions is how can I easily put the MSB and LSB together to get my 16 bit integer?

There must be a simple way of doing this.

Thanks

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: LSB and MSB

Post by medelec35 »

Hi Graham,
This post should help

Martin
Martin

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: LSB and MSB

Post by Lord Grezington »

Thanks Martin...

Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

Re: LSB and MSB

Post by Lord Grezington »

Please note...

Not sure its my ignorance with I2C, but using the MIC2_Recieve_Byte_Transaction macro always doubles the device_ID when used on hardware...

IE = Device_ID = 0x64

Gives

0xB8 when measured on scope

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LSB and MSB

Post by Benj »

Hello,

The transaction macro assumes you pass in the 7-bit address and the macro then manages the 1-bit read/write flag for you. So if you need to send 0x64 including the read/write bit then you should pass the value 0x32.

Post Reply