I2C Master Slave problem

11 May 2011

Hi,

I am new with I2C and I need help. Using the provided libraries,i have not been able to get the I2C to work correclty. I use configuration as show on my pictures. When I want to send some data to slave some line can't be executed.

/media/uploads/elektronika1/i2c_configuration.png

/media/uploads/elektronika1/report.png

11 May 2011

How do you know that particular line fails to execute?

What happens?

12 May 2011

Well, when I start my program, I watch SDA and SCL line on my scope and everything what is happening is that SDA and SCL line drop to logical 0 what is START condition for I2C, and after that there is no any changes in signal level (SDA and SCL line are flat).

Also I use terminal application for debugging my code, and I succeed to print out messages to PC (line 11 in my code, but not and line 19). That mean line 18 master.write(addr,master_data,3) can't be executed. Other word my program is stop in line 18 and he can't execute line below.

12 May 2011

If your diagram is correct, you have tx connected to tx and rx to rx rather than tx to rx.

12 May 2011

Oops, ignore that comment I should have looked at the I2C boxes not the serial.

12 May 2011

I think what is happening is that the master.write and slave.read calls need to execute concurrently. master.write sends something and slave.read is supposed to respond but slave.read can't respond until master.write finishes executing but master.write can't finish until slave.read executes and so on.

If you were doing this on two separate processors there wouldn't be a problem.

The code would need to be written to use interrupts to make this work.

17 May 2011

Hi, Clark.

I was offline for a while so I didn't see your reply.

You were right, if I do this on two separate processors there is no problem.

Thanks a lot. Branko