DS2431: 1024- B it, 1-Wire EEPROM
8 of 23
WRITING WITH VERIFICATION
To write data to the DS2431, the scratchpad has to be used as intermediate storage. First the master issues the
Write Scratchpad command to specify the desired target address, followed by the data to be written to the
scratchpad. Note that Copy Scratchpad commands must be performed on 8-byte boundaries, i. e., the 3 LSBs of
the target address (T 2..T 0) mus t be equal to 000b. If T2..T0 are sent with no n- zero v alu es, the copy function wil l be
blocked. Under certain conditions (see W rite Scratchpad comm and) the master will receive an inverted CRC16 of
the command, address (actual address sent) and data at the end of the Write Scratchpad command sequence.
Knowing this CRC value, the master can compare it to the value it has calculated itself to decide if the
comm unication was suc ces sful and proc eed to the Copy Scra tchpa d command. If the m aster c ould not recei ve the
CRC16, it should send the Read Scratchpad command to verify data integrity. As a preamble to the scratchpad
data, the DS2431 repeats the target address TA1 and TA2 and sends the contents of the E/S register. If the PF
flag is s et, dat a d id n ot arr ive corr ectly in the s cr atc hpad or th er e was a l os s of po wer s ince dat a was las t written to
the scratchpad. The master does not need to continue reading; it can start a new trial to write data to the
scratchpad. Similarly, a set AA flag together with a cleared PF flag indicates that the device did not recognize the
Write command. If everything went correctly, both flags are cleared. Now the master can continue reading and
verifying every data byte. After the master has verified the data, it can send the Copy Scratchpad command, for
example. This command must be followed exactly by the data of the three address registers, TA1, TA2, and E/S.
The master should obtain the contents of these registers by reading the scratchpad.
MEMORY FUNCTION COMMANDS
The Memory Function Flow Chart (Figure 7) describes the protocols necessary for accessing the memory of the
DS2431. An exam ple on how to use these f unctions to write t o and read from the device is included at the end of
this document. The comm unic ation bet wee n m as ter and DS2431 t akes place e ith er at re gul ar spee d ( def au lt, O D =
0) or at Overdrive Speed (OD = 1). If not explicitly set into the Overdrive Mode, the DS2431 assumes regular
speed.
WRITE SCRATCHPAD COMMAND [0Fh]
The Write Scratchpad command applies to the data memory, and the writable addresses in the register page. In
order for the scratchpad data to be valid for copying to the array, the user must perform a Write Scratchpad
comm and of 8 bytes starting at a valid row boundar y. The W rite Scratchpad comm and accepts invalid addresses,
and partial rows, but subsequent Copy Scratchpad commands are blocked.
After issuing the W rite Scratchpad command, the master must first provide the 2-byte target address, followed by
the data to be written to the scratchpad. The data is written to the scratchpad starting at the byte offset of T2:T0.
The ES bits E2:E0 are loaded with the starting byte offset, and increment with each susequent byte. Effectively,
E2:E0 is the byte offset of the last full byte written to the scratchpad. Only full data bytes are accepted.
When executing the Write Scratchpad command, the CRC generator inside the DS2431 (Figure 13) calculates a
CRC of the entire data stream, starting at the command code and ending at the last data byte as sent by the
master. T his CRC is generated using the CRC1 6 polynomial b y first clearing the CRC generator and then shif ting
in the command code (0FH) of the W rite Scratchpad comm and, the Target Addresses (TA1 and T A2), and all the
data bytes. Note that the CRC16 calculation is performed with the actual TA1 and TA2 and data sent by the
master . The m aster may end the W rite Scratc hpad com mand at an y time. Howev er, if th e end of the scratc hpad is
reached (E2:E0 = 111b), the master may send 16 read-time slots and receive the CRC generated by the DS2431.
If a Write Scratchpad is attempted to a write-protected location, the scratchpad is loaded with the data already in
mem ory, rather than the data transm itted. Similar ly, if the target address pag e is in EP ROM mode, th e scratchpad
is loaded with the bitwise logical AND of the transmitted data and data already in memory.