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.

routine to read i2c device

Status
Not open for further replies.

Daljeet12

Member level 4
Joined
Jun 16, 2018
Messages
78
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
648
I need help on following routine

routine to read i2c device
Code:
unsigned char I2CRead()
{
	unsigned char i, Data=0;
	for (i = 0; i < 8; i++) {
		SCL = 1;
		if(SDA)
			Data |=1;
		if(i<7)
			Data<<=1;
		SCL = 0;
	}
	return Data;
}

What it would be return in loop1 loop2 and loop 3 ?
 

Hi,

What it would be return in loop1 loop2 and loop 3 ?
The series to parallel shifted signal of SDA. MSB first.

BTW:
* I2C needs to keep on timing and needs to keep on protocol (like addresing a device).
* Most mucrocontrollers include I2C hardware interface.
* Read the I2C specification.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top