27220 Parallax Inc, 27220 Datasheet - Page 204

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
' *** Receive Byte ***
I2C_RX_Byte_Nak:
I2C_RX_Byte:
I2C_RX:
' *** Stop Sequence ***
I2C_Stop:
Behind the Scenes
While it is possible to implement rudimentary timekeeping functions in code with
PAUSE, problems arise when BASIC Stamp needs to handle other activities. This is
especially true when an application needs to handle time, day, and date. The
cleanest solution is an external real-time clock. In this experiment, we’ll use the
Maxim-Dallas DS1307. Like the 24LC32, the DS1307 connects to its host though an
I2C bus. Unlike the 24LC32, however, it is not addressable, so only one DS1307 can
exist on a given I2C bus.
Once programmed the DS1307 runs by itself and accurately keeps track of seconds,
minutes, hours, day of week, date, month, year (with leap year compensation
through the year 2100), and a control register for the SQW output. As a bonus, the
DS1307 contains 56 bytes of RAM (registers $08 - $3E) that can be used for general-
purpose storage. And for projects that use main’s power, the DS1307 is easily
backed-up by a 3v Lithium battery (good for up to 10 years).
Like most I2C devices, the DS1307 is register-based, that is, each element of the
time and date is stored in its own register (memory address). For convenience, two
i2cAck = Nak
GOTO I2C_RX
i2cAck = Ack
SHIFTIN SDA, SCL, MSBPRE, [i2cWork\8]
SHIFTOUT SDA, SCL, LSBFIRST, [i2cAck\1]
RETURN
LOW SDA
INPUT SCL
INPUT SDA
RETURN
' no Ack = high
' Ack = low
' get byte from device
' send ack or nak
' I2C stop bit sequence

Related parts for 27220