Difference between revisions of "Unit DS1307"
(6 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
=== Description === | === Description === | ||
---- | ---- | ||
+ | |||
+ | '''Maxim DS1307 Real Time Clock Driver unit''' | ||
The Maxim DS1307 is an I2C interface, battery backed real time clock chip with full BCD clock and calendar and 56 bytes of software accessible NVRAM. The chip supports 12 or 24 hour format and is widely used in low cost RTC devices available from a range of suppliers. | The Maxim DS1307 is an I2C interface, battery backed real time clock chip with full BCD clock and calendar and 56 bytes of software accessible NVRAM. The chip supports 12 or 24 hour format and is widely used in low cost RTC devices available from a range of suppliers. | ||
Line 33: | Line 35: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 chip | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 chip''' <code> DS1307_CHIP_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 71: | Line 73: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 RTC register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 RTC register''' <code> DS1307_REG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 100: | Line 102: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 control and status register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 control and status register''' <code> DS1307_REG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 132: | Line 134: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 seconds register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 seconds register''' <code> DS1307_REG_SECONDS_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
| <code>DS1307_REG_SECONDS_CH = $80;</code> | | <code>DS1307_REG_SECONDS_CH = $80;</code> | ||
− | | Clock Halt bit (1 to Disable / 0 to Enable the clock) | + | | Clock Halt bit (1 to Disable/0 to Enable the clock) |
|- | |- | ||
| <code>DS1340_REG_SECONDS_nEOSC = $80;</code> | | <code>DS1340_REG_SECONDS_nEOSC = $80;</code> | ||
Line 143: | Line 145: | ||
|- | |- | ||
| <code>MCP794XX_REG_SECONDS_ST = $80;</code> | | <code>MCP794XX_REG_SECONDS_ST = $80;</code> | ||
− | | Clock Stop Bit (1 to Enable / 0 to Disable the clock) | + | | Clock Stop Bit (1 to Enable/0 to Disable the clock) |
|- | |- | ||
|} | |} | ||
Line 149: | Line 151: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 hour register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 hour register''' <code> DS1307_REG_HOUR_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
| <code>DS1307_REG_HOUR_12HR = $40;</code> | | <code>DS1307_REG_HOUR_12HR = $40;</code> | ||
− | | 12/24 hour bit (1 = 12 hour mode / 0 = 24 hour mode) | + | | 12/24 hour bit (1 = 12 hour mode/0 = 24 hour mode) |
|- | |- | ||
| <code>DS1307_REG_HOUR_PM = $20;</code> | | <code>DS1307_REG_HOUR_PM = $20;</code> | ||
− | | AM/PM bit (1 = PM / 0 = AM) (Only in 12 hour mode) | + | | AM/PM bit (1 = PM/0 = AM) (Only in 12 hour mode) |
|- | |- | ||
| <code>DS1340_REG_HOUR_CENTURY_EN = $80;</code> | | <code>DS1340_REG_HOUR_CENTURY_EN = $80;</code> | ||
Line 169: | Line 171: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''MCP794XX weekday register | + | <div style="font-size: 14px; padding-left: 12px;">'''MCP794XX weekday register''' <code> MCP794XX_REG_WEEKDAY_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
| <code>MCP794XX_REG_WEEKDAY_VBATEN = $08;</code> | | <code>MCP794XX_REG_WEEKDAY_VBATEN = $08;</code> | ||
− | | Battery Backup Enabled (1 to Enable / 0 to Disable) | + | | Battery Backup Enabled (1 to Enable/0 to Disable) |
|- | |- | ||
|} | |} | ||
Line 180: | Line 182: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1337 month register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1337 month register''' <code> DS1337_REG_MONTH_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 191: | Line 193: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 control register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1307 control register''' <code> DS1307_REG_CONTROL_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 214: | Line 216: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1337 control register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1337 control register''' <code> DS1337_REG_CONTROL_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 246: | Line 248: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1340 control register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1340 control register''' <code> DS1340_REG_CONTROL_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 266: | Line 268: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1340 flag register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1340 flag register''' <code> DS1340_REG_FLAG_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 277: | Line 279: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''DS1337 status register | + | <div style="font-size: 14px; padding-left: 12px;">'''DS1337 status register''' <code> DS1337_REG_STATUS_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 294: | Line 296: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''RX8025 control1 register | + | <div style="font-size: 14px; padding-left: 12px;">'''RX8025 control1 register''' <code> RX8025_REG_CONTROL1_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 305: | Line 307: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''RX8025 control2 register | + | <div style="font-size: 14px; padding-left: 12px;">'''RX8025 control2 register''' <code> RX8025_REG_CONTROL2_* </code></div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
Line 325: | Line 327: | ||
---- | ---- | ||
− | '' | + | |
+ | '''DS1307 RTC time''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PDS1307RTCTime = ^TDS1307RTCTime;</code> | ||
+ | |||
+ | <code>TDS1307RTCTime = array[0..6] of Byte;</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''DS1307 RTC device''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PDS1307RTCDevice = ^TDS1307RTCDevice;</code> | ||
+ | |||
+ | <code>TDS1307RTCDevice = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|''RTC Properties'' | ||
+ | |- | ||
+ | | <code>RTC:TRTCDevice;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|''DS1307 Properties'' | ||
+ | |- | ||
+ | | <code>I2C:PI2CDevice;</code> | ||
+ | | The I2C device this RTC is connected to | ||
+ | |- | ||
+ | | <code>Address:Word;</code> | ||
+ | | The I2C address of the device | ||
+ | |- | ||
+ | | <code>Chip:LongWord;</code> | ||
+ | | The chip type (eg DS1307_CHIP_DS1307) | ||
+ | |- | ||
+ | | <code>RTCReg:Byte;</code> | ||
+ | | The register offset for the RTC | ||
+ | |- | ||
+ | | <code>NVRAMReg:Byte;</code> | ||
+ | | The register offset for the NVRAM | ||
+ | |- | ||
+ | | <code>NVRAMSize:Byte;</code> | ||
+ | | The NVRAM size | ||
+ | |- | ||
+ | | <code>ControlReg:Byte;</code> | ||
+ | | The control register offset | ||
+ | |- | ||
+ | |colspan="2"|''Statistics Properties'' | ||
+ | |- | ||
+ | | <code>ReadCount:LongWord;</code> | ||
+ | | Number of direct RTC/NVRAM/Control reads to the device | ||
+ | |- | ||
+ | | <code>WriteCount:LongWord;</code> | ||
+ | | Number of direct RTC/NVRAM/Control writes to the device | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
---- | ---- | ||
− | '' | + | ''None defined'' |
=== Function declarations === | === Function declarations === | ||
Line 344: | Line 409: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 355: | Line 420: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCStart(RTC:PRTCDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCStart(RTC:PRTCDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceStart API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use RTCDeviceStart instead. |
|- | |- | ||
|} | |} | ||
Line 367: | Line 432: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCStop(RTC:PRTCDevice):LongWord;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCStop(RTC:PRTCDevice):LongWord;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceStop API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use RTCDeviceStop instead. |
|- | |- | ||
|} | |} | ||
Line 379: | Line 444: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCGetTime(RTC:PRTCDevice):Int64;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCGetTime(RTC:PRTCDevice):Int64;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceGetTime API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use RTCDeviceGetTime instead. |
|- | |- | ||
|} | |} | ||
Line 391: | Line 456: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
<pre style="border: 0; padding-bottom:0px;">function DS1307RTCSetTime(RTC:PRTCDevice; const Time:Int64):Int64;</pre> | <pre style="border: 0; padding-bottom:0px;">function DS1307RTCSetTime(RTC:PRTCDevice; const Time:Int64):Int64;</pre> | ||
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' | + | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of RTCDeviceSetTime API for DS1307 RTC</div> |
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
− | | | + | | Not intended to be called directly by applications, use RTCDeviceSetTime instead. |
|- | |- | ||
|} | |} | ||
Line 410: | Line 475: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 422: | Line 487: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 434: | Line 499: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 446: | Line 511: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 458: | Line 523: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 470: | Line 535: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 482: | Line 547: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 494: | Line 559: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 506: | Line 571: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- |
Latest revision as of 04:11, 24 April 2018
Return to Unit Reference
Description
Maxim DS1307 Real Time Clock Driver unit
The Maxim DS1307 is an I2C interface, battery backed real time clock chip with full BCD clock and calendar and 56 bytes of software accessible NVRAM. The chip supports 12 or 24 hour format and is widely used in low cost RTC devices available from a range of suppliers.
This driver extends the real time clock API to include functions for directly reading and writing the NVRAM which could be used for storing device specific information and configuration or for non volatile storage of keys, passwords or tokens.
Constants
DS1307_*
DS1307_RTC_DESCRIPTION = 'Maxim DS1307 Real Time Clock';
|
Description of DS1307 device |
DS1307_MIN_TIME = 125911584000000000;
|
Time starts at 01/01/2000 00:00:00 (MM/DD/YY HH:MM:SS) |
DS1307_MAX_TIME = 157469183990000000;
|
Time ends at 12/31/2099 23:59:59 (MM/DD/YY HH:MM:SS) |
DS1307_CHIP_*
DS1307_CHIP_DS1307 = 0;
|
|
DS1307_CHIP_DS1337 = 1;
|
|
DS1307_CHIP_DS1338 = 2;
|
|
DS1307_CHIP_DS1339 = 3;
|
|
DS1307_CHIP_DS1340 = 4;
|
|
DS1307_CHIP_DS1388 = 5;
|
|
DS1307_CHIP_DS3231 = 6;
|
|
DS1307_CHIP_M41T00 = 7;
|
|
DS1307_CHIP_MCP794XX = 8;
|
|
DS1307_CHIP_RX8025 = 9;
|
DS1307_REG_*
DS1307_REG_SECONDS = $00;
|
00-59 |
DS1307_REG_MINUTE = $01;
|
00-59 |
DS1307_REG_HOUR = $02;
|
00-23 (or 1-12am,pm) |
DS1307_REG_WEEKDAY = $03;
|
01-07 |
DS1307_REG_DAY = $04;
|
01-31 |
DS1307_REG_MONTH = $05;
|
01-12 |
DS1307_REG_YEAR = $06;
|
00-99 |
DS1307_REG_*
DS1307_REG_CONTROL = $07;
|
Also DS1338 |
DS1337_REG_CONTROL = $0e;
|
|
DS1340_REG_CONTROL = $07;
|
|
DS1340_REG_FLAG = $09;
|
|
DS1337_REG_STATUS = $0f;
|
|
DS1339_REG_ALARM1_SECONDS = $07;
|
|
RX8025_REG_CONTROL1 = $0e;
|
|
RX8025_REG_CONTROL2 = $0f;
|
DS1307_REG_SECONDS_*
DS1307_REG_SECONDS_CH = $80;
|
Clock Halt bit (1 to Disable/0 to Enable the clock) |
DS1340_REG_SECONDS_nEOSC = $80;
|
|
MCP794XX_REG_SECONDS_ST = $80;
|
Clock Stop Bit (1 to Enable/0 to Disable the clock) |
DS1307_REG_HOUR_*
DS1307_REG_HOUR_12HR = $40;
|
12/24 hour bit (1 = 12 hour mode/0 = 24 hour mode) |
DS1307_REG_HOUR_PM = $20;
|
AM/PM bit (1 = PM/0 = AM) (Only in 12 hour mode) |
DS1340_REG_HOUR_CENTURY_EN = $80;
|
|
DS1340_REG_HOUR_CENTURY = $40;
|
MCP794XX_REG_WEEKDAY_*
MCP794XX_REG_WEEKDAY_VBATEN = $08;
|
Battery Backup Enabled (1 to Enable/0 to Disable) |
DS1337_REG_MONTH_*
DS1337_REG_MONTH_CENTURY = $80;
|
DS1307_REG_CONTROL_*
DS1307_REG_CONTROL_OUT = $80;
|
Output Control (Output level of SQW/OUT pin when SQWE = 0) |
DS1338_REG_CONTROL_OSF = $20;
|
|
DS1307_REG_CONTROL_SQWE = $10;
|
Square-Wave Enable (When set to 1, enables the oscillator output) |
DS1307_REG_CONTROL_RS1 = $02;
|
Rate Select 1 (See datasheet for values) |
DS1307_REG_CONTROL_RS0 = $01;
|
Rate Select 2 (See datasheet for values) |
DS1337_REG_CONTROL_*
DS1337_REG_CONTROL_nEOSC = $80;
|
|
DS1339_REG_CONTROL_BBSQI = $20;
|
|
DS3231_REG_CONTROL_BBSQW = $40;
|
same as BBSQI |
DS1337_REG_CONTROL_RS2 = $10;
|
|
DS1337_REG_CONTROL_RS1 = $08;
|
|
DS1337_REG_CONTROL_INTCN = $04;
|
|
DS1337_REG_CONTROL_A2IE = $02;
|
|
DS1337_REG_CONTROL_A1IE = $01;
|
DS1340_REG_CONTROL_*
DS1340_REG_CONTROL_OUT = $80;
|
|
DS1340_REG_CONTROL_FT = $40;
|
|
DS1340_REG_CONTROL_CALIB_SIGN = $20;
|
|
DS1340_REG_CONTROL_M_CALIBRATION = $1f;
|
DS1340_REG_FLAG_*
DS1340_REG_FLAG_OSF = $80;
|
DS1337_REG_STATUS_*
DS1337_REG_STATUS_OSF = $80;
|
|
DS1337_REG_STATUS_A2I = $02;
|
|
DS1337_REG_STATUS_A1I = $01;
|
RX8025_REG_CONTROL1_*
RX8025_REG_CONTROL1_2412 = $20;
|
RX8025_REG_CONTROL2_*
RX8025_REG_CONTROL2_PON = $10;
|
|
RX8025_REG_CONTROL2_VDET = $40;
|
|
RX8025_REG_CONTROL2_XST = $20;
|
Type definitions
DS1307 RTC time
PDS1307RTCTime = ^TDS1307RTCTime;
TDS1307RTCTime = array[0..6] of Byte;
DS1307 RTC device
PDS1307RTCDevice = ^TDS1307RTCDevice;
TDS1307RTCDevice = record
RTC Properties | |
RTC:TRTCDevice;
|
|
DS1307 Properties | |
I2C:PI2CDevice;
|
The I2C device this RTC is connected to |
Address:Word;
|
The I2C address of the device |
Chip:LongWord;
|
The chip type (eg DS1307_CHIP_DS1307) |
RTCReg:Byte;
|
The register offset for the RTC |
NVRAMReg:Byte;
|
The register offset for the NVRAM |
NVRAMSize:Byte;
|
The NVRAM size |
ControlReg:Byte;
|
The control register offset |
Statistics Properties | |
ReadCount:LongWord;
|
Number of direct RTC/NVRAM/Control reads to the device |
WriteCount:LongWord;
|
Number of direct RTC/NVRAM/Control writes to the device |
Public variables
None defined
Function declarations
Initialization functions
procedure DS1307Init;
Note | None documented |
---|
DS1307 RTC functions
function DS1307RTCStart(RTC:PRTCDevice):LongWord;
Note | Not intended to be called directly by applications, use RTCDeviceStart instead. |
---|
function DS1307RTCStop(RTC:PRTCDevice):LongWord;
Note | Not intended to be called directly by applications, use RTCDeviceStop instead. |
---|
function DS1307RTCGetTime(RTC:PRTCDevice):Int64;
Note | Not intended to be called directly by applications, use RTCDeviceGetTime instead. |
---|
function DS1307RTCSetTime(RTC:PRTCDevice; const Time:Int64):Int64;
Note | Not intended to be called directly by applications, use RTCDeviceSetTime instead. |
---|
DS1307 helper functions
function DS1307ReadRTC(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307WriteRTC(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307ReadNVRAM(RTC:PRTCDevice; Offset:Byte; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307WriteNVRAM(RTC:PRTCDevice; Offset:Byte; Buffer:Pointer; Size:LongWord):LongWord;
Note | None documented |
---|
function DS1307ReadControl(RTC:PRTCDevice; var Control:Byte):LongWord;
Note | None documented |
---|
function DS1307WriteControl(RTC:PRTCDevice; Control:Byte):LongWord;
Note | None documented |
---|
function DS1307DefaultRTCTime(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord):Boolean;
Note | None documented |
---|
function DS1307FileTimeToRTCTime(RTC:PRTCDevice; const FileTime:Int64; Buffer:Pointer; Size:LongWord):Boolean;
Note | None documented |
---|
function DS1307RTCTimeToFileTime(RTC:PRTCDevice; Buffer:Pointer; Size:LongWord; var FileTime:Int64):Boolean;
Note | None documented |
---|
Return to Unit Reference