Searching \ for '2 bytes into unsigned long' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=bytes+into+unsigned
Search entire site for: '2 bytes into unsigned long'.

Truncated match.
PICList Thread
'2 bytes into unsigned long'
1997\04\21@090013 by FrankT

picon face
Via I2c I receive 2 bytes HighByte and LowByte.

What is the fastest way (with MPLABC) to convert them into a unsigned long
variable?

Frank Temmerman.

1997\04\21@093914 by tjaart

flavicon
face
FrankT wrote:
>
> Via I2c I receive 2 bytes HighByte and LowByte.
>
> What is the fastest way (with MPLABC) to convert them into a unsigned long
> variable?
>
> Frank Temmerman.

Define your long variable MylongVar.
Define HighByte and LowByte at the same addresses as MyLongVar
ie :
unsigned long   MyLongVar
unsigned        LowByte @ &MylongVar
unsigned        HighByte @ &MylongVar+1

Loading the correct values into HighByte and LowByte will
automatically load it into MyLongVar

--
Friendly Regards

Tjaart van der Walt
spam_OUTtjaartTakeThisOuTspamwasp.co.za
_____________________________________________________________
| Another sun-deprived R&D Engineer slaving away in a dungeon |
|             WASP International  http://wasp.co.za           |
|             GSM and GPS value-added applications            |
|  Voice : +27-(0)11-622-8686   |   Fax : +27-(0)11-622-8973  |
|_____________________________________________________________|

1997\04\21@095159 by Mike Smith

flavicon
face
---------
> From: FrankT <.....gymnaKILLspamspam@spam@COMPUSERVE.COM>
> To: PICLISTspamKILLspamMITVMA.MIT.EDU
> Subject: 2 bytes into unsigned long
> Date: Monday, 21 April 1997 22:16
>
> Via I2c I receive 2 bytes HighByte and LowByte.
>
> What is the fastest way (with MPLABC) to convert them into a unsigned
long
> variable?

Well, using CCS's C I do this -

put this in your h file

struct two_byte {
       BYTE lsb;
       BYTE msb;
};

typedef union split_tag {
       long L;   // note!  a long in CCS is 16 bits
       struct two_byte TB;
} split_type;

then declare

split_type a, b;
a.TB.lsb = 123; // manipulate as 8 bit vars
a.TB.msb = 456;

b.L = a.L; // manipulate as 16 bit vars


Advantage is that there is no arithmetic ops involved.  Things to check are
whether your C is big or little endian, and whether it supports structs /
unions.

MikeS
<.....mikesmith_ozKILLspamspam.....relaymail.net>

1997\04\21@121414 by Mike Smith

flavicon
face
Sorry if this is duped.  PICLIST gave me an anomalous error message.

---------
> From: FrankT <EraseMEgymnaspam_OUTspamTakeThisOuTCOMPUSERVE.COM>
> To: PICLISTspamspam_OUTMITVMA.MIT.EDU
> Subject: 2 bytes into unsigned long
> Date: Monday, 21 April 1997 22:16
>
> Via I2c I receive 2 bytes HighByte and LowByte.
>
> What is the fastest way (with MPLABC) to convert them into a unsigned
long
> variable?

Well, using CCS's C I do this -

put this in your h file

struct two_byte {
       BYTE lsb;
       BYTE msb;
};

typedef union split_tag {
       long L;   // note!  a long in CCS is 16 bits
       struct two_byte TB;
} split_type;

then declare

split_type a, b;
a.TB.lsb = 123; // manipulate as 8 bit vars
a.TB.msb = 456;

b.L = a.L; // manipulate as 16 bit vars


Advantage is that there is no arithmetic ops involved.  Things to check are
whether your C is big or little endian, and whether it supports structs /
unions.

MikeS
<@spam@mikesmith_ozKILLspamspamrelaymail.net>

1997\04\22@015217 by Mike Smith

flavicon
face
<sigh> Why is this happening?

<<Your message  is being returned to  you unprocessed because it  appears
to have
already been distributed to the PICLIST list. That is, a message with
identical
text (but  possibly with different  mail headers) has  been posted to  the
list
recently, either by you or by someone else. If you have a good reason to
resend
this message  to the  list (for instance  because you have  been notified
of a
hardware failure with  loss of data), please  alter the text of  the
message in
some way and resend  it to the list. Note that altering  the "Subject:"
line or
adding blank lines at  the top or bottom of the message  is not sufficient;
you
should  instead add  a  sentence or  two  at  the top  explaining  why you
are
resending the  message, so that the  other subscribers understand why  they
are
getting two copies of the same message.>>

message runs something like -

> From: FrankT <KILLspamgymnaKILLspamspamCOMPUSERVE.COM>
> To: RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU
> Subject: 2 bytes into unsigned long
> Date: Monday, 21 April 1997 22:16
>
> Via I2c I receive 2 bytes HighByte and LowByte.
>
> What is the fastest way (with MPLABC) to convert them into a unsigned
long
> variable?

Well, using CCS's C I do this -

put this in your h file

struct two_byte {
       BYTE lsb;
       BYTE msb;
};

typedef union split_tag {
       long L;   // note!  a long in CCS is 16 bits
       struct two_byte TB;
} split_type;

then declare

split_type a, b;
a.TB.lsb = 123; // manipulate as 8 bit vars
a.TB.msb = 456;

b.L = a.L; // manipulate as 16 bit vars


Advantage is that there is no arithmetic ops involved.  Things to check are
whether your C is big or little endian, and whether it supports structs /
unions.

MikeS
<spamBeGonemikesmith_ozspamBeGonespamrelaymail.net>


I've tried what the diagnostic suggests, but with the same results.  If
this is duped, someone tell me to shut up.

1997\04\22@113625 by Gerhard Fiedler

picon face
At 15:23 22/04/97 +0930, Mike Smith wrote:
><sigh> Why is this happening?
>
><<Your message  is being returned to  you unprocessed because it  appears
>to have
>already been distributed to the PICLIST list. That is, a message with
>identical
>text (but  possibly with different  mail headers) has  been posted to  the
>list
>recently, either by you or by someone else. If you have a good reason to

The message you tried to send I already read -- so it's really duped. What
happens is that some crazy mail server at Microchip sends out messages that
posts to the piclist couldn't be posted, when in reality they were posted.
Which probably made you post it again (and some others too).

Hope somebody checks this out.

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...