Thermochron Code Migration

Abstract

This document captures the evolution of the Analog Devices (ADI) family of iButton Thermochron devices, specifically the DS1921, DS1922, and DS1925, and outlines the key differences and advantages of each. It also describes the necessary software changes needed to migrate from one device to another.

Introduction

The Analog Devices (ADI) dime-sized family of 1-Wire® Thermochron iButton loggers are rugged, battery-powered modules that independently measure and log temperature at user-specified intervals. This document captures the evolution of the ADI family of iButton Thermochron devices, specifically the DS1921, DS1922 and DS1925, and outlines the key differences and advantages of each. It also describes the necessary software changes needed to migrate from one device to another.

Memory Characteristics

There are various memory technologies in the semiconductor industry that provide unique performance and power advantages. Memory types range from electrically erasable programmable read-only memory (EEPROM), flash, static random-access memory (SRAM), to others. The end application typically dictates which memory technology is the most beneficial. Factors for memory selection include if data can be volatile or if it must be retained when the device's power is removed. Power consumption is also an important factor, especially if the device is battery powered. Table 1 describes the integrated memory characteristics for each device.

Table 1. Memory Characteristics
Device Memory Type Volatile?
DS1921 SRAM Yes
DS1922 SRAM Yes
DS1925 FLASH No

Table 1 indicates the DS1925 is the only device with data log memory that can be extracted even if the internal battery is exhausted. The data is permanently lost in the DS1921 and DS1922 devices upon battery depletion. The battery is not replaceable in all three devices.

Flash memory takes significantly more power to program than SRAM. However, the ability for Flash memory to retain its data when battery power is depleted is an attractive feature for some applications. As the DS1925's memory is nonvolatile, the device's front-end and state machine were changed to allow power harvesting from the 1-Wire interface, enabling the downloading of data when the device's battery is exhausted. This power transfer requirement altered the command set used by previous devices, which introduced the External Power Command or XPC. The XPC functionality was added to many DS1925 commands to eliminate the load on the battery during mission configuration and data downloads.

The configuration register at memory address 0200h is very similar for the DS1921 and DS1922, but with a few differences that need attention when migrating code between the two. On the surface, the DS1925's configuration register looks very similar to its siblings, however, there are significant differences in register locations and decoding, thus requiring more work for code migration.

Command Set Code Migration

All three devices share common 1-Wire ROM Function commands (e.g., Read ROM, Skip ROM, Match ROM, etc.), except for the Resume ROM command, which is not present in the DS1921. Therefore, there are no ROM function command code changes when switching from the DS1921 to either one of its siblings.

While many of the device specific commands are shared between the DS1921 and DS1922, there are some important differences. The DS1925's new state machine architecture and register map definition are a significant departure from both its predecessors.

Table 2 shows the cross compatibility between the device specific commands. As indicated in the table, only two commands are fully compatible with no code changes required across all three devices. Both the DS1922 and DS1925 introduce password protection, causing changes in the command byte sequencing. The software changes required for the commands are as following.

Table 2. Device-Specific Command Compatibility
DS1921 COMMAND DS1922 COMMAND DS1925 COMMAND CODE CHANGES?
Write SPAD (0Fh) Write SPAD (0Fh) Write SPAD (0Fh) No
Read SPAD (AAh) Read SPAD (AAh) Read SPAD (AAh) No
Copy SPAD (55h) Copy SPAD w/PW (99h) XPC Copy SPAD (99h) Yes
Read Memory (F0h) Read Memory w/PW + CRC (69h) XPC Read Memory (44h) Yes
Read Memory with CRC (A5h) Read Memory w/PW + CRC (69h) XPC Read Memory (44h) Yes
Clear Memory (3Ch) Clear Memory w/PW (96h) XPC Clear Memory (96h) Yes
Convert Temperature (44h) Forced Conversion (55h) XPC Forced Conversion (4Bh) Yes
Start Mission – No Command Start Mission w/PW (CCh) XPC Start Mission (DDh) Yes
Stop Mission – No Command Stop Mission w/PW (33h) XPC Stop Mission (BBh) Yes

Copy Scratchpad

DS1921 to DS1922 Code Migration


  • Change command byte from 55h to 99h.
  • Host must transmit the 64-bit password after the ES byte.
  • The copy time is unchanged at 2µs per byte.
  • The remainder of the flow is unchanged from DS1921.

DS1921 to DS1925 Code Migration


  • Change function name to XPC Copy Scratchpad.
  • Change command byte from 55h to 99h.
  • Add the XPC Command (66h) after the ROM Level command and transmit the length byte.
  • Transmit the XPC Copy Scratchpad command following the XPC Command.
  • Follow the remainder of the flow in the data sheet, which differs from DS1921.

DS1922 to DS1925 Code Migration


  • Change function name to XPC Copy Scratchpad.
  • No change in command byte.
  • Add the XPC Command (66h) after the ROM Level command and transmit the length byte.
  • Transmit the XPC Copy Scratchpad command following the XPC Command.
  • Follow the remainder of the flow in the data sheet, which differs from DS1922.

Read Memory

DS1921 to DS1922 Code Migration


  • Change command byte from F0h to 69h.
  • Host must transmit the 64-bit password after the target address.
  • The host's code must be modified to receive a CRC16 at the end of each page.

DS1921 to DS1925 Code Migration


  • Change function name to XPC Read Memory.
  • Change command byte from F0h to 44h.
  • Add the XPC Command (66h) after the ROM Level command and transmit the length byte.
  • Transmit the XPC Read Memory command following the XPC Command.
  • Host must transmit the 64-bit password after the target address.
  • Follow the remainder of the flow in the data sheet, which differs from DS1921.

Register Map

The register pages both configure the part for a mission (time, sample rate, etc.) and provide status for various items, such as alarms, sample count, and others. Table 3 shows the register address space for various items and how they map across the family of loggers. This section discusses the code migration needed for each item in Table 3.

Table 3. Register Map
REGISTER DS1921 MEMORY ADDRESS DS1922 MEMORY ADDRESS DS1925 MEMORY ADDRESS
Real-Time Clock 0200h to 0206h 0200h to 0205h 0200h to 0203h
RTC Alarm 0207h to 020Ah - -
Temperature Alarms 020Bh to 020Ch 0208h to 0209h 0208h to 0209h
Sample Rate 020Dh 0206h to 0207h 0206h to 0207h
Control 020Eh Various Various
Latest Temperature 0211h 020Ch to 020Dh 020Ch to 020Dh
Mission Start Delay 0212h to 0213h 0216h to 0218h 0216h to 0218h
Status 0214h Various Various
Mission Timestamp 0215h to 0219h 0219h to 021Eh 0219h to 021Ch
Mission Samples Counter 021Ah to 021Ch 0220h to 0222h 0220h to 0222h
Device Samples Counter 021Dh to 021Fh 0223h to 0225h 0223h to 0225h
Flavor - 0226h 0226h
Read Access Password - 0228h to 022Fh 0228h to 022Fh
Full Access Password - 0230h to 0237h 0230h to 0237h

Real-Time Clock (RTC)

The RTC registers reside in the same address locations for both devices. However, the DS1921 utilizes a Day of Week at address 0203h, which does not exist on the DS1922, causing the addresses to shift down by one. Functionality remains the same for the remaining registers, so no code changes are needed aside from changing the target addresses.


DS1921 to DS1925 Code Migration


While the DS1925's RTC registers reside in the same address space, the decoding is vastly different. The RTC uses a 32-bit value that represents the number of seconds since midnight of January 1, 1970. This is referred to as Epoch time. Addresses 0204 and 0205h are not used.


DS1922 to DS1925 Code Migration


The code migration for the DS1922 is the same as the DS1921 (see above).

RTC Alarm

The DS1922 and DS1925 do not have this feature, so there's no migration path.

Temperature Alarms

DS1921 to DS1922 Code Migration


The temperature alarm equation slightly differs; refer to the data sheet for details.


DS1921 to DS1925 Code Migration


The temperature alarm equation slightly differs; refer to the data sheet for details.


DS1922 to DS1925 Code Migration


The temperature alarm equation slightly differs; refer to the data sheet for details.

Sample Rate

DS1921 to DS1922 Code Migration


The DS1921's sample rate is in minutes, while the DS1922 has a resolution down to one second. Refer to the data sheet for details.


DS1921 to DS1925 Code Migration


The DS1925 sample rate is different and requires code changes. Refer to the data sheet for details.


DS1922 to DS1925 Code Migration


The memory address locations for the sample rate are the same for these two devices and operate the same. However, the DS1925 should not have a sample rate faster than five minutes. The flash memory in the DS1925 uses more current than SRAM, which requires time for the battery to recover. The flash memory provides the ability to retain its contents if the battery is depleted, but at the cost of a slower sample rate.

Control Register

DS1921 to DS1922 Code Migration


The control register in the DS1921 provides access to various features shown in Table 4. The DS1922 has some functionality integrated into commands such as Start/Stop Mission, while others reside in various memory addresses enabled using memory writes.

Table 4. Control Register Bits
DS1921 Control Register DS1922 Register Addresses
020Eh Bit 0: TAS – Timer Alarm Search 0215h Bit4: WFTA – Waiting for Temperature Alarm
020Eh Bit 1: THS – Temp. High Alarm Search 0214h Bit1: THF – Temp. High Alarm Flag
020Eh Bit 2: TLS – Temp. Low Alarm Search 0214h Bit0: TLF – Temp. Low Alarm Flag
020Eh Bit 3: RO – Rollover Enable/Disable 0213h Bit4: RO – Rollover Control
020Eh Bit 4: EM – Enable Mission 0215h Bit1: MIP – Mission in Progress
020Eh Bit 5: 0 -
020Eh Bit 6: EMCLR – Memory Clear Enable Not implemented
020Eh Bit 7: EOSC – Enable Oscillator 0212h Bit0: EOSC – Enable Oscillator

Timer Alarm Search (Bit 0)


The DS1922 does not have a similar feature.


Temperature High Alarm Search (Bit 1)


The DS1922's THF flag indicates if the temperature exceeded the threshold. Like the DS1921, a Conditional Search ROM identifies alarming devices. This flag is bit 1 at address 0214h in the DS1922's register.


Temperature Low Alarm Search (Bit 2)


The DS1922's TLF flag indicates if the temperature dropped below the threshold. Like the DS1921, a Conditional Search ROM identifies alarming devices. This flag is bit 0 at address 0214h in the DS1922's register.


Rollover Enable/Disable (Bit 3)


This functionality is the same between the two devices, just at a different register address location in the DS1922.


Enable Mission (Bit 4)


The DS1921's Enable Mission (bit 4) is written directly, while the DS1922 uses the Start/Stop Mission commands while the mission status is reflected in the MIP bit (bit 1).


Memory Clear Enable (Bit 6)


Unlike the DS1921, the DS1922 does not require an enable bit to clear its memory. The Memory Clear command erases the memory without any gating bits. Both devices have a Memory Cleared (MEMCLR) status bit. These reside in bit 3 at address 0215h of the DS1922 and bit 6 at address 0214h of the DS1921.


Enable Oscillator (Bit 7)


This bit controls the crystal oscillator of the RTC. The bits are logic opposites for each device, so a code change is required to enable the RTC. A logic 1 in the DS1921 stops the oscillator, while starting it in the DS1922.


DS1921 to DS1925 Code Migration


The code changes are like the DS1922, except for the rollover bit, which is not implemented in the DS1925.

Table 5. Control Register Bits
DS1921 Control Register DS1922 Register Addresses
020Eh Bit 0: TAS – Timer Alarm Search 0215h Bit4: WFTA – Waiting for Temperature Alarm
020Eh Bit 1: THS – Temp. High Alarm Search 0214h Bit1: THF – Temp. High Alarm Flag
020Eh Bit 2: TLS – Temp. Low Alarm Search 0214h Bit0: TLF – Temp. Low Alarm Flag
020Eh Bit 3: RO – Rollover Enable/Disable Not implemented
020Eh Bit 4: EM – Enable Mission 0215h Bit1: MIP – Mission in Progress
020Eh Bit 5: 0 -
020Eh Bit 6: EMCLR – Memory Clear Enable Not implemented
020Eh Bit 7: EOSC – Enable Oscillator 0212h Bit0: EOSC – Enable Oscillator

DS1922 to DS1925 Code Migration


The DS1922 does not have a Control register like the DS1921. The functionality of this register spans register addresses 0210h to 0215h for both the DS1922 and DS1925. Code changes require the use of the XPC Command as outlined earlier in this document to read and write to these register locations.

Latest Temperature

DS1921 to DS1922 Code Migration


The DS1921's latest temperature conversion is stored at address 0211h, while the DS1922's spans two bytes at addresses 020Ch and 020Dh. Code changes require targeting the new starting address as well as reading the two temperature data bytes instead of one. Additionally, the code should interrogate the Temperature Logging Format Selection (TLFS) bit in the Mission Control register to determine the resolution, enabling the host to select the proper equation for temperature calculations.


DS1921 to DS1925 Code Migration


The DS1925's latest temperature conversion results span two bytes at addresses 020Ch and 020Dh. Code changes require the use of the XPC Command and require targeting the new starting address as well as reading the two temperature data bytes instead of one. Additionally, the code should interrogate the Temperature Logging Format Selection (TLFS) bit in the Mission Control register to determine the resolution, enabling the host to select the proper equation for temperature calculations.


DS1922 to DS1925 Code Migration


The register locations are the same for both devices. Code changes require the use of the XPC Command.

Mission Start Delay

DS1921 to DS1922 Code Migration


The DS1922's Mission Start Delay Counter differs in size and address location. The DS1922's counter is three bytes in length, so code changes are required for reading, writing, and addressing this register location.


DS1921 to DS1925 Code Migration


The DS1925's Mission Start Delay Counter differs in size and address location. The DS1925's counter is three bytes in length, so code changes are required for reading, writing, and addressing this register location. Code changes require the use of the XPC Command.


DS1922 to DS1925 Code Migration


The register location and operation of the Mission Start Delay Counter is the same for both devices. However, code changes require the use of the XPC Command.

Status

The status register provides the host system with various indicators. The DS1921 has these flags collectively in a single register, while the DS1922 and DS1925 has them spanning two registers. Use Table 6 to migrate DS1921 code to the DS1922 and DS1925. The DS1921's MIP, TLF, THF, and TAF bits can only be written to 0. All other bits are read-only. All the bits in Table 6 are read-only for both the DS1922 and DS1925. No register addresses changes are required when migrating from DS1922 to DS1925 as they remain unchanged. However, code changes require the use of the XPC Command.

Mission Timestamp

The mission timestamp indicates the date and time when the first mission sample is taken. The time of the first temperature sample of the mission can be computed by adding the Mission Timestamp with the Mission Start Delay.

Counter. All three devices represent it differently across multiple registers, so refer to the device data sheet for mapping between devices and how to decode the register values.

Mission and Device Samples Counter

The number of samples is represented with a three-byte value representing a 24-bit unsigned integer for all three devices; however, the register addresses differ (see Table 3).

Flavor

The flavor byte located at address 0226h for both the DS1922 and DS1925 indicates the device type (DS1922L, DS1922T, etc.), which are the same devices (excluding DS1925), but with differing temperature ranges. This indicator is needed because the DS1922x family of devices have the same Family Code, making them indistinguishable from each other. This feature is not available on the DS1921.

Read and Full Access Passwords

The read and full access passwords reside in the same address space for both the DS1922 and DS1925 (Table 3). Write the passwords before enabling them through the EPW bit located at address 0228h.

Conclusion

This document provides guidance on how to migrate software from one family of Thermochron devices to another without spending significant time referring the device data sheets.