Has anyone gotten this to work? Unfortunately, I was counting on this in my design. I recently discovered the errata sheet, which lists some workarounds. I guess I'll be trying them. I am really wishing I had picked an older chip about now.
Guest
Posted: Thu Feb 26, 2009 11:06 pm
Actually, I have it working now. My compiler is version 4.086. I noticed that the I2C_Read() would return a value even if the slave was stopped at a breakpoint. I then figured that the master might be reading before the slave had time to respond. I put a 1 MS delay before the read and the master gets the proper data.
I believe that the delay is just a workaround, but at least I can make some progress again. I think the master should wait for the slave, maybe the slave is not stretching the clock properly. There is some info in the 16F886 errata sheet, but I haven't digested it completely. I plan to look at it some more in the near future.
Here is the code fragment that worked:
Code:
// Read from the slave board and display the data.
i2c_start();
i2c_write(0xA0); // send i2c address w/ read bit clear
i2c_write(0x00); // send data address
i2c_start(); // restart for read
i2c_write(0xA1); // send i2c address w/ read bit set
delay_ms(1); // wait for slave to respond
data = i2c_read(0); // read data w/ no ack
i2c_stop();
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum