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.

How to integrate all values in integer value using C?

Status
Not open for further replies.

nprao4

Newbie level 1
Joined
Sep 25, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,287
Hello

I am using 24bit adc interfacted to AT89s52. i am reading the output in 8bit formate i.e (low byte, mid byte, high byte) i want to integrate all the value into a integer value.i am using keil software.

low byte=33h
mid byte =04h
high byte =02h
i want to make the value as (value=020433h)

how can do this using c

Rao
 

Re: Interger value

Code:
typedef unsigned char u8;
typedef unsigned long u32;

u32 combine( u8 high, u8 mid, u8 low )
{
   return ( ( (u32)high << 16 ) | ( (u32)mid << 8 ) | (u32)low );
}

...

/* do the conversion from bytes to long */
u32 result = combine( 0x02, 0x04, 0x33 );
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top