DS1307 - how long to read?

Andrew Cowan

Senior Member
How long does it take to read the time off a DS1307? I will be using a 20X2 running at 64MHz. (Using the hi2cin command).

If it takes too long, is the best way to speed it up to read the time into another PICAXE, serial out the data, and background serial in?

Thanks

Andrew
 
Last edited:

westaust55

Moderator
How many registers are you intending to read?
Need more information before anyone can give you a clear answer on total time.

Also for your information,

the DS1307 is a slow i2c bus part so needs the i2cslow "switch".

If you switch to the DS1338-33C, it
- can still operate at 5V,
- has a pin for pin compatability, and
- works with the fast i2c bus so you can use the i2cfast "switch".

The "C" version required an external 32.768kHz crystal as per the DS1307.
 

Andrew Cowan

Senior Member
That's great - I haven't heard of the DS1338-33C before. I would want to read the hour, minute and second values. Being able to use i2cfast sounds promising!

Edit - I think I'll use a 28X2-3v, not a 20X2.

A
 
Last edited:

westaust55

Moderator
Educated guess here on time required

Assumptions:
1. 28X2 at 64MHz = 16 x 28X1 at 4MHz
2. Typical instruction time for 28X1 is 0.250ms

So the BASIC program HI2CIN instruction setup time as will take roughly 0.016ms

There is no delay akin to the 750ms conversion time for the DS18B20 temp sensor.

The actual i2c communications requires 5 bytes if reading all the required registers in one HI2CIN command as:
1. Send slave address
2. Send first register
3. Fetch seconds
4. Fetch mins
5. Fetch hours

8 bits in each byte but also allow for Start, Stop and Acknowledge bits so we are looking at around 55 bits.

At 400kHz (i2cFAST), each bit takes 0.0025ms) so all up comms time will be around 0.14ms thus all up time should (?) be around 0.15 to 0.16ms.

It would take virtually just as ling to retrieve the data from a second PICAXE as you propose as an alternative.

Someone with an X2 part operating at 64MHz could verify or correct the above.




Use of the 3.3V X2 part could be a good move.
24LC series EEPROMs will work at 3.3V as do quite a lot of newer chips and modules.
 
Last edited:

BCJKiwi

Senior Member
Time to read is the speed of i2c which is pretty short.
However time will only be updated in the Clock chip(s) once per second anyway.

So is the Q related to program cycle time, or, to time updates?
 

inglewoodpete

Senior Member
2. Typical instruction time for 28X1 is 250ms
Err.... that would be 250uS, wouldn't it?

Andrew,

i2c does all the protocol handling on its own. If you use serial via another chip, you will have processing overheads of sending, receiving and managing the the incoming data. Even if you use hserial at phenominal speeds, you still have to set/reset pointers and clear flags for the scratchpad.

If you have a DS1307, try it. I think you will be pleasantly surprised.
 

westaust55

Moderator
Err.... that would be 250uS, wouldn't it?

Andrew,

i2c does all the protocol handling on its own. If you use serial via another chip, you will have processing overheads of sending, receiving and managing the the incoming data. Even if you use hserial at phenominal speeds, you still have to set/reset pointers and clear flags for the scratchpad.

If you have a DS1307, try it. I think you will be pleasantly surprised.
well spotted IWP. Yes, should read 0.250ms

and yes, the X1/X2 i2c comms is through hardware. The BASIC program time I mentioned was that required for the BASIC interpreter would need to set up the i2c values to send in the first instance.
Then as IWP mentiones the hardware does most of the rest in 0.14ms.
As a funciton of the i2c protocol and baud rate, a faster PICAXE cannot improve on the i2c comms speed.
 

Dave E

Senior Member
I just started looking into the DS1307 (i2cslow) real time chip. I have one reading 5 registers with a 20X2.

At 16MHz, the read time is about 550uS. At 8MHz, a tad over 1 mS. I can not get a read above 16 MHz. Not very familliar with i2c protocol but it looks like the Picaxe is sending clock output but the DS1307 doesn't send back any info at speeds above 16MHz.
If someone knows what needs to be done to get the DS1307 working at a higher rate, let me know.

Dave E
 

Dave E

Senior Member
Told you that I was new to the DS chip. I forgot to change the set up to the chip when I changed the freq.

At 16MHz and DS set to i2cslow_16: read is 1.1mS
At 32MHz and DS set to i2cslow_32: read is 0.9mS
At 64MHz and DS set to i2cslow_64: read is 0.7mS

Dave E

PS
was getting good reads at faster rate if I left DS setup at i2cslow_4

Will need to investigate that.
 

Dave E

Senior Member
Interesting:

At 20X2 speed of m64, DS set to i2cslow_4: could not get a read
At 20X2 speed of m64, DS set to i2cslow_8: read took 250uS
At 20X2 speed of m64, DS set to i2cslow_16: read took 350uS

Dave E
 
Top