27220 Parallax Inc, 27220 Datasheet - Page 205

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
modes of reading and writing are available: register and block. With register access,
individual elements can be written or read. With block access we take advantage of
the automatic incrementing of the DS1307’s internal address pointer; this allows
groups of bytes to be written to or read from the DS1307 by specifying the starting
address of the block.
Of note are the Set_Clock and Get_Clock subroutines that use block mode to
read and write blocks of eight bytes from/to the DS1307.
subroutines take advantage of the fact that PBASIC allows the RAM space to be
treated like an array – even when an array is not explicitly declared. You’ll see in
both routines that
minutes register corresponds to secs(1), hours to secs(2), etc.
shows the how the clock registers are mapped to the implicit secs() array
As you can see in the listing, the array elements are based on the declaration order
of the same variable type; changing the order of declaration will change the position
within the array. This is a very powerful technique as PBASIC does not allow the
aliasing of declared array elements. Using the technique above gives us the greatest
possible programming flexibility.
There is a small variation in the Set_Clock and Get_Clock subroutines having to
do with the I2C protocol specification. In Set_Clock, all time registers are written
to the DS1307 in a loop (using the secs array). In Get_Clock, though, only the
first seven bytes are read in the loop; the final byte is read after. The reason for this
is that the I2C specification requires a Nak after the final read operation.
This program demonstrates the conversion of BCD to decimal values, and back. The
DS1307 stores clock registers as BCD which can be directly displayed using the HEX2
modifier with DEBUG, but cannot be modified mathematically.
available for Byte and Word variables makes BCD-to-Decimal conversion a snap:
secs
mins
hrs
day
date
month
year
control
secs
is used as the base of the array. What this means is that the
VAR
VAR
VAR
VAR
VAR
VAR
VAR
VAR
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
' secs(0)
' secs(1)
' secs(2)
' secs(3)
' secs(4)
' secs(5)
' secs(6)
' secs(7)
Also note that these
The NIB modifier
The listing below

Related parts for 27220