Proposed plan to write multiple bytes on I2C device

Status
Not open for further replies.
Hello @KlausST

I came across your statement in thread https://www.edaboard.com/threads/increment-the-counter-of-rtc-in-the-lcd.400648/ and thought I should try
Hi,

what about doing first things first?
Drawing a flow chart?

It´s not only for us, it´s mainly for yourself.
In my eyes it´s more important for unexperienced programmers.

Klaus
This is my proposed plan to write I2C device Ds1307 Please give feedback on this. If it looks right then I will present my next plan to read DS1307


 

Hi,

Your chart shows exactly how I interprete Figure 4 of the datasheet.

Necessary information from the datasheet:
The master can then transmit zero or more bytes of data with the DS1307 acknowledging each byte received. The register pointer automatically increments after each data byte are written. The master will generate a STOP condition to terminate the data write.
This information is important, because not all devices support auto address increment.

Well done.
Very detailed computer designed flow chart. With additional information. Perfect.



Klaus
 
Do you use any tool to draw the waveform?

I want to make a waveform diagram for the given flowchart because I'm having trouble understanding the timing diagram. if I show a timing diagram, then it will be easy to understand where I am having problems understanding concepts. I would post a paper diagram next few hours
 

Hi,

No.
I´m somehow oldfashioned in this way and often use just a pencil and a paper.

But you may refer to the datasheet, or use a screenshot of the datasheet timing diagram and and a simple picture editor. Even MS Word may do the job.

What microcontroller do you decide to use? Often they have built in I2C interfaces. Usually one can rely on their timing to comply with the I2C standard.

Klaus
 

But you may refer to the datasheet, or use a screenshot of the datasheet timing diagram and and a simple picture editor. Even MS Word may do the job.
This image I edited in paint It's just for statdard I2C

START condition generate when SDA goes High-low while SCL is High
STOP condition generate when SDA goes low-high while SCL is High
Data bit is only valid when SCL is High

 

Hi
It's just for statdard I2C
Rely on this. This is "the standard" ... and all IC manufacturers should keep on this, too.
Everything else are just [rare] exceptions.

***
START, STOP: correct

***
A side note on the pictures:
They are not true "timing diagrams", because they don´t include any timing informations.
These are sketches. The timing is not to scale. They show example waveforms.

***
Data bit is only valid when SCL is High
As a "raw" definition.
OUTput of data to SDA always should be when SCL is LOW.
INput of data from SDA is (if m not mistaken) at the falling edge of SCL.
So due to setup and hold timing specifications it may be allowed to be a bit "over the SCL edge" --> read the timing specification.

***
But as already said: If you use a microcontroller with built in I2C interface, then you don´t need to care for every exact timing. The hardware will make it right.

Klaus
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…