Maker Pro
Maker Pro

Driving a DS1393 from a PIC or AVR

M

Mike Deblis

Jan 1, 1970
0
Hi,

Has anyone tried talking to a DS1393 or similar 3-wire RTC from either
a PIC or AVR (or similar) - these RTCs are not SPI - they have a
bi-directional I/O pin.

Thanks,

Mike
 
A

Anthony Fremont

Jan 1, 1970
0
Mike Deblis said:
Hi,

Has anyone tried talking to a DS1393 or similar 3-wire RTC from either
a PIC or AVR (or similar) - these RTCs are not SPI - they have a
bi-directional I/O pin.

Isn't it really just I2C protocol with a chip select as the "third"
wire?
 
R

Roger Hamlett

Jan 1, 1970
0
Anthony Fremont said:
Isn't it really just I2C protocol with a chip select as the "third"
wire?
I'd be very 'wary' about chosing this chip, since it is no longer listed
by Dallas/Maxim, with the data sheet 'links', going to a blank page...

Best Wishes
 
A

Anthony Fremont

Jan 1, 1970
0
I'd be very 'wary' about chosing this chip, since it is no longer listed
by Dallas/Maxim, with the data sheet 'links', going to a blank page...

Hmm.... I just went to www.maxim-ic.com and typed in ds1393 in the part
number search field, clicked the "PART NO. SEARCH" button and came up
with this page:
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4359

The datasheet link worked fine for me as well. It's one datasheet for
the DS1390, DS1391, DS1392, and DS1393. Where did you look?
 
J

Jeroen

Jan 1, 1970
0
Mike Deblis said:
Hi,

Has anyone tried talking to a DS1393 or similar 3-wire RTC from either
a PIC or AVR (or similar) - these RTCs are not SPI - they have a
bi-directional I/O pin.

Thanks,

Mike

I'm using a DS1302 for a project which also has only 3 wires. It's really
simple and just like SPI, except that it's half duplex.

You can easily bit bang it. Switch the data in/output to output, make /CS
low, output 8 databits+clocks, then change the in/output to input, and issue
the neccessary clocks and sample the input. 20-25 lines of C code.

something like:

(assuming AVR, port B... 0=cs 1=dat 2=clk)

#define CS 1
#define DAT 2
#define CLK 4
..
..
..
DDRB|=DAT; // switch the data line to output
PORTB&=~CS; // select the chip
for (i=0;i<8;i++) // output 8 bits of command
{
if (command & 128) PORTB|=DAT;
else PORTB&=~DAT;

PORTB|=CLK; // Toggle clk. DS sample the data bit
command<<=1; // Shift command, maybe insert some NOPs here to delay
if it goes too fast
if (i!=7) PORTB&=~CLK; // Don't set CLK low at the last bit to prevent
shorting two outputs together
}

DDRB&=~DAT; // Switch to input
PORTB&=~CLK; // Set CLK low, DS13XX switches to output, takes at max 160ns

data=0;
for (i=0;i<8;i++) // Fetch 8 bits
{
data<<=1;
if (PORTB & DAT) data|=1;

PORTB|=CLK;
nop();
PORTB&=~CLK;
}

PORTB&=~CS; // End transfer

I've successfully interfaced many chips this way and for an RTC, speed is
not really an issue. Just follow the timing diagrams in the datasheet.

Actually, Dallas has an appnote of this, app note 2361...

Hope this helps,

Jeroen
 
Top