LED Clock: Troubleshooting the DS1302 Interface

My LogoChip is still reading garbage from the DS1302 when it (1302) is powered at 5V and good data only when the 1302 is running off the backup battery at 3V. I spent some time looking at it this weekend and discovered a number of interesting things (which aren’t all related to the voltage problem), but no solution yet.

LogoChip Logo Include Files

Because LogoChip Logo has no documented means to reference or include other files into code, I was doing something hacky and ugly with m4. Yesterday, I accidentally (by loading the wrong file into the LogoChip console and getting a different error message than I expected) discovered that LogoChip Logo does support an include command: include foo (no punctuation required).

That’s fantastic news, because it allowed me to clean up all the m4 ugliness, do away with the need for a Makefile, etc. I switched all of my DS1302 code to use the native include command, and will do the same for the 6276 code the next time I work with the LEDs.

Burst Write Not Working

The DS1302 supports burst read and write operations, where you access multiple memory locations sequentially. I know my burst read operation works, because that’s how I’m pulling the complete timestamp out of the device to display in my test code. But for some reason, my burst write doesn’t work–I can only set the time using individual write statements, not using the burst write.

I’ve corrected two problems with the burst write code already. I had somehow forgotten to send the burst write address to the device, so I was trying to read from the clock chip without it having any idea what it was supposed to be sending. And I had omitted the control register from the end of my burst because I didn’t want to change the control bits. However, I reread in the datasheet that a burst write to the clock registers isn’t committed until all eight bytes have been written, so I added a dummy write for the status register (which contains only a write-protect bit that I don’t want to enable anyway).

Still no joy. I’m starting to feel like I’ll need a logic analyzer to solve some of these problems.

5V / 3V

A handful of experimental observations about whatever’s going on:

  • Writing to the device registers only works at 5V, not at 3V. (Writing at 3V doesn’t change the values in before/after read tests.) Reading the registers only works at 3V, not at 5V. (Reading at 3V gives garbled but repeatable results.)
  • The problem doesn’t appear to be dependent on the source of the 5V supply–the results are the same when running the LogoChip from a battery and the DS1302 from the bench supply, both from the Curiously Strong LogoChip battery, or both from the bench supply.
  • The problem doesn’t seem to be specifically timekeeping related–I get similar results reading/writing the clock registers and reading/writing the 31-byte NVRAM that the 1302 provides.

It just occurred to me while writing this that I don’t know whether the problem is related to the 1302′s operating voltage or its supply source–that is, whether the difference is that it’s running on 3V instead of 5V, or that it’s supplied by VCC1 instead of VCC2. That’s definitely worth trying tonight.

Leave a Reply