This works perfectly but the problem is that, it uses USI hardware, and i can't use that, in my hardware PB1 and PB4 pins are used to sniff the I2C data.
PB1 will Sniff SCL line and PB4 will Sniff SDA line.
I don't know, why i am not able to detect the start condition, with this code can any one please help me in this.
Please review your code, or trace it's execution with Proteus source level debugger.
You'll notice that none of the expected events like
Code:
if((sda_state_prev == HIGH) & (sda_state == LOW))
will ever happen because sda_state_prev is set equal to sda_state before. Obviously previous state must be set after checking for input state changes not before.
I send 0xD0 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 from PIC16F877A to DS1307 and tried to capture the packet using ATtiny85.
And i got the result, in my buffer i am getting all values correctly, but only in one cycle.
How to detect the stop condition and restart again. (I haven't taken care of NACK, please help if there is any way)
Please let me know what i am doing wrong.
Try this. There is an asm and also C source code for ATTiny85 I2C Sniffer. I have not tested it. I don't know whether it uses I2C pins for sniffing or GPIO pins.