I'm doing a project with the Arduino Mega2560, and I’m looking for a way to communicate with the DS1305 real time clock, but I need to use the so-called 3-wire mode, not the 4-wire “true” SPI everyone else seem to be using. The 1305 chip supports both modes.
I had previously used the DS1307 which uses I2C protocol (connected to SDA/CLK pins), and it was relatively easy thanks to some example code I found that used the Wire.h library for communication.
Now I want to use the DS1305 instead, but I can’t seem to find any good source or library on the net that directly solves my problem, and I’m not experienced enough to know how easy it would be to write a low-level library using 3-wire communication myself.
This is what I have:
The DS1305 chip is connected as on the first page of the datasheet “Typical operating circuit”, with its SCLK pin connected to SCL and the SDI/SDO pins both connected to SDA. Also the CE (chip enable) is connected to pin 41. With the SERMODE pin connected to GND, the chip should be in 3-wire mode.
I have found a library for the DS1305 which uses the SPI mode, so that one should have the logic down for controlling time and alarm registers. I would need to convert that library to use 3-wire.
I have also found a library for another chip, the related DS1302, which also uses 3-wire protocol, but of course the functionality and meaning of the internal registers are somewhat different.
Combining these two libraries should give the desired result?
Has someone implemented this already, and I just couldn't find it?
I have connected the DS1305 to the microcontrollers SCL and SDA pins, as I had the previous 1307, but the DS1302 3-wire library I have uses common digital pins 5, 6 and 7. From the 1302 library linked below it looks like I have to manually control these pins, including changing the pin mode of the data i/o pin, so I guess I have to rewire those pins first?
I basically need to know if this is a feasible way to go, before I go waste a lot of hours trying to get it to not work. But I'm learning here, so any help would be appreciated!
The two libraries that could be combined to get what I need is linked here:
DS1305 library (SPI): http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1220985468
DS1302 library (3-wire): https://github.com/msparks/arduino-ds1302