[Solved]DS1307 communication I2c - Page 1
Forum section: electronics / general

author: BlogRahul
author_rank: Regular Contributor
timestamp: December 15, 2021, 04:37:19 pm
content: What would be the message length of the I2C bus?When 8-bit uC writing two register's of DS1307 [ Seconds Address (00h), Minutes address (01h)]Bus length : start bit, 0xD0, 0x00, 0x11, stop bit;I think the I2C bus sends a total of 26 bits and 29 clock pulses to write Seconds and Minutes registersDoes I2C send a total of 26 bits or 24 bits?

author: woofy
author_rank: Frequent Contributor
timestamp: December 15, 2021, 05:26:48 pm
content: Start and stop are not so much bits as sequences, there is no SCL clock. Its SDA going low/high while SCL is high. They take time though so count them as bits if you choose.so 24 data bits3 Ack bitsPlus start/stop if you want to count them.Just to be clear, your example writes 11 to the seconds register only, you're not writing anything to the minutes reg.

author: BlogRahul
author_rank: Regular Contributor
timestamp: December 16, 2021, 11:25:46 am
content: .Quote from: woofy on December 15, 2021, 05:26:48 pmcorrect It should be anything like 0xD0, 0x00, 0x11 0x12Quote from: woofy on December 15, 2021, 05:26:48 pmWhen the master writes to the slave, Who generates ack/NAK signal master or slave?

author: woofy
author_rank: Frequent Contributor
timestamp: December 16, 2021, 01:46:18 pm
content: Quote from: BlogRahul on December 16, 2021, 11:25:46 amThe slave.When reading from the slave its the master that must provide the ack/nack, therefore the ack/nack is generated by whoever is receiving the data byte.The SCL clock is always generated by the master.

author: BlogRahul
author_rank: Regular Contributor
timestamp: December 17, 2021, 10:29:20 am
content: What are the steps to read the sequence of bytes from the I2C device? like if I need to read two registers seconds and minutes What will happen?Here is my understandingMaster send repeat start on the I2C busMaster send slave address 0xD1 reading modeMaster generates ACK/NAKMaster sends the address of seconds 0x00Master generates ACKMaster sends the address of minutes 0x01Master generates NAK after the last byte

author: voltsandjolts
author_rank: Unknown
timestamp: December 17, 2021, 10:47:56 am
content: (1) Download PulseView fromhereand install it(2) Download example DS1307 data fromhere(the .sr files)(3) Open a .sr file in PulseView to see a capture of I2C data. Then add the decoder for DS1307.(4) Zoom and pan to view all the detail you want to see in DS1307 transactions. See example screenshot attached.

author: woofy
author_rank: Frequent Contributor
timestamp: December 17, 2021, 11:25:05 am
content: Quote from: BlogRahul on December 17, 2021, 10:29:20 amYou need tell the DS1307 where you want to read from, also read again my post above on who generates the ack.To read seconds and minutes:1. Send a start sequence2. Send 0xD0, slave generates ack. (Yes, its a write command!)3. Send 0x00, the address of the seconds reg, slave generates ack.4. Send start sequence again, (restart)5. Send 0xD1, slave generates ack. (Now its a read command)6. Read seconds reg, master generates ack.7. Read minutes reg, master generates ack.8. Send stop sequence.

author: retiredfeline
author_rank: Frequent Contributor
timestamp: December 17, 2021, 11:30:24 am
content: Further to the previous answer figure 6 on page 13 of the Maxim datasheet shows the transaction.

author: BlogRahul
author_rank: Regular Contributor
timestamp: December 17, 2021, 11:53:01 am
content: Quote from: woofy on December 17, 2021, 11:25:05 amAren't you missing NAk at point 7 ? Master should be sent NAK after the last byte

author: woofy
author_rank: Frequent Contributor
timestamp: December 17, 2021, 12:24:13 pm
content: Quote from: BlogRahul on December 17, 2021, 11:53:01 amI am referring to who sends the ack. Yes, its a NACK at that point.