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.

Question About C for AT89c52 ( char to int convertion)

Status
Not open for further replies.

eng_ahmed22

Full Member level 3
Joined
Jun 7, 2005
Messages
189
Helped
20
Reputation
40
Reaction score
5
Trophy points
1,298
Activity points
2,944
Salaam All
i have a question.
i have some chars stored in EEPROM. I2C.
i want to read add. 0x00 and add. 0x01 from the I2C and merge them to obtain int.
here is my code:

/*************************************************************/
int x,int_temp;

x = (int)(I2C_READ(0x01));
x *=256;
int_temp = (int)(I2C_READ(0x00));
x = (x) | (int_temp);
/
************************************************************/

i repeat this code many times to get all data from the I2C.
is that correct??
is this contains any error??
what happens is that it read some wrong data (not all)
i also tried this code:


/*************************************************************/
int x,int_temp;

x = (int)(I2C_READ(0x01));
x<<8;
int_temp = (int)(I2C_READ(0x00));
x = (x) | (int_temp);
/
************************************************************/

but the same errors :cry:
plz Help
thanks alot
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top