I have very strange problem in my circuit. Namely, I have 24LC01 EEPROM connected to my PIC32. I made "library" for reading from and writing to the memory. What is happening is that only first reading of data gives me correct data, while every later attempt gives me wrong data. The experiment is following. I wrote one page with 0x30 (0 Ascii character), so from address 0 - 7. Next I read 8 bytes starting from address 0. First reading is correct and I print 00000000. Next attempt to read fives me 0 and 7 unknown characters. This happens in the same manner until MC is restarted.

Here are some waveforms.

On the first wave, you can see that control word is sent, it was ACKed by the slave, then comes the memory address at which to start, in this case 0. Then comes ACK and repeated start event. Next, control word is sent again, but this time with reading flag set. After follows first charcter 0x30, and so on, till the 8th.

First read, start of communication.

At the end if the first reading attempt, you can see that NACK after the last byteis sent, followed by the STOP condition on the bus.

enter image description here

Next, you can see start of communication of the second attempt. First control word is sent correct and was ACKed. Next came address where the data should be read from (again 0), it was also ACKed. Next master sends repeated reading command, and the second control word with reading flag set (btw address of the device is 1010xxx). The second control word was also ACKed, and the came first byte from the memory location 0, which is 0x30 and as you can see it is also ok, but at the end of that byte SDL goes high and stays there till the end of the reception.

enter image description here

On the next photo is shown the end of the wave. As you can see SDL was always high, and only STOp condition is sent at the end.

enter image description here

What might be the problem here?

  • \$\begingroup\$ One too many clocks \$\endgroup\$
    – Andy aka
    Nov 13, 2015 at 15:37
  • \$\begingroup\$ No, there is just enough clock pulses. \$\endgroup\$
    – Nexy_sm
    Nov 13, 2015 at 16:46
  • \$\begingroup\$ I can't tell, is your master ACKing the first data byte? If you aren't and the slave is seeing a NACK, it may stop responding. \$\endgroup\$
    – DoxyLover
    Nov 13, 2015 at 20:10
  • \$\begingroup\$ I cant find if there can stop master from generating ACK. The code works in the first reading, after that ACk event is not sent after first byte is received. \$\endgroup\$
    – Nexy_sm
    Nov 13, 2015 at 23:05
  • \$\begingroup\$ Try a logic analyzer rather than an oscilloscope.Or if you don't have one, you could try to simply break the signal to detect if the master/slave give you an ACK or NACK. \$\endgroup\$ Nov 14, 2015 at 17:36

1 Answer 1


The problem was wrong assumption that flag to set ACK/NACK will be reseted after I disable I2C pin. So, the firmware was wrong.

So at the end of the first reading cycle the flag for NACK is set, and never changed back to ACK.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.