SPI RTC

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

I have one general question about RTCs that work on SPI.

Currently I'm using I2C RTC and my problem is that I can't read all RTC registers in "one shot". I have to read every register separately. So I'm thinking to move on SPI RTC.

So, in general do SPI RTC have internal address counter so that I'm able to read all register at once?

What are your experiences?

Regards !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why can't you read them all in one I2C transaction? You can read multiple bytes in one I2C transaction, and the device should increment its internal address counter for each byte.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What I2C RTC do you have?

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, now I realize it has been some time since I dug into RTC interfacing.

My first thought to OP's question was "What does it matter if it is separate operations?" then I thought that an increment could occur during a multiple read sequence.

So, back to the DS1305 (SPI) datasheet:

Quote:
READING FROM THE CLOCK REGISTERS
Buffers are used to copy the time and date register at the beginning of a read. When reading in burst mode, the user copy is static while the internal registers continue to increment.

Whew. So no need to re-examine my oft-used "driver".

But OP has an I2C RTC. So, off to the DS1307 datasheet:

Quote:
When reading or writing the time and date registers, secondary (user) buffers are used to prevent errors when the internal registers update. When reading the time and date registers, the user buffers are synchronized to the internal registers on any I2C START. The time information is read from these secondary registers while the clock continues to run. This eliminates the need to re-read the registers in case the internal registers update during a read.
Indeed, then, it would appear that a multi-byte read should be used.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've just received an e-mail form tech, support and they say it is not possible to read all registers at once. In fact my RTC is pretty old, 10 years now, so everything is clear now.

Thnx for help, guys!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which chip are you using?

I am sure that the DS1307 or PCF8563 are both over 10 years old.

To read all of those chips' RTC registers is about 10 I2C bytes. i.e. 90 bits @ 100kHz or 900us.

Even if you need to read one register at a time, 400us per register. It is pretty unlikely that you have a rollover during the 2.8ms to read 7 registers.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP PMed me with this:

xtal_88 wrote:
larryvc wrote:
What I2C RTC do you have?

https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=966569#966569

Hi larryvc !

My RTC is S-35390A

I've just received an e-mail form tech, support and they say it is not possible to read all registers at once. In fact my RTC is pretty old, 10 years now, so everything is clear now.

Regards !

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

According to the datasheet, you can read multiple bytes in one IIC transaction, just not all registers in one big go; but you can read the time in one I2C transaction, and the date too, and that is what counts.

The datasheet does not specifically mention any double buffering to prevent reading half baked time data.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From a brief look at the data sheet, you can read all the RTC registers in one go.

It appears to use different Slave addresses to access the different register/function.

This seems a little profligate with Slave addresses but actually makes the I2C transfer simpler.

So I can't see any great problem with using your existing S-35390A chip.

In answer to your original question, most SPI or I2C chips allow sequential data reads. You choose whichever one fits your pcb most conveniently.

David.