Chip: DS2431, 1-wire EEPROM (1Kbyte).
Bus:1-Wire, <2.2Kohm pull-up resistor required.
Power requirements: 2.8volts to 5.25volts.
References:datasheet,
Hack a Day demonstration.
Complete Bus Pirate session log for this demonstration.
I couldn't include some formatting and HTML tables in an Instructable, you can see the original
at the Dangerous Prototypes blog.
The DS2431 draws power from the pull-up resistor and doesn't need an external supply or decoupling capacitor.
1-Wire needs a strong pull-up resistor, a maximum of 2.2Kohms.
The Bus Pirate's on-board pull-up resistors are 10K, too weak to properly power the DS2431 during writes. You must use a 2.2Kohm or smaller external resistor between power and the 1-Wire bus pin. If you have difficulties writing data, make sure your pull-up resistor is large enough. The 3EEPROM explorer board includes a 1800 ohm pull-up resistor (R1) on the 1-Wire bus so no external resistor is needed.SetupIf you're using a Bus Pirate, connect it to the 3EEPROM board or DS2431 as shown in the chart image below. The DS2431 doesn't require the power supply pin, it's used on the 3EEPROM board to power the large pull-up resistor for the 1-Wire bus.
InterfacingPress 'm' in the Bus Pirate terminal and select 1-Wire mode. Enable the on-board power supplies (big 'W') and check the voltage monitor (v).
Step 1, find the device address1-WIRE>(0xf0)
<<<1-Wire search macro 1WIRE ROM COMMAND: SEARCH (0xF0)
Found devices at:
Macro 1WIRE address
1.0x2D 0x54 0xD2 0xEF 0x00 0x00 0x00 0x2B
<<<DS2431 unique ID*DS2431 1K EEPROM
<<<device type is knownFound 0x01 devices.
The first 10 device IDs are available by MACRO, see (0).
1-WIRE>
Each 1-Wire device has a unique 8 byte ID. 1-Wire has a search procedure that detects the ID of all attached devices. The Bus Pirate implements the 1-Wire search as macro (240). Type '(240)' in the Bus Pirate terminal to start the 1-Wire search.
Each device address is printed, known devices are identified. The first ten 1-Wire device addresses are stored as macros, in this example our DS2431 address is available by typing '(1)' in the terminal.
Step 2, write 8 bytes to the scratch pad 1-WIRE>(0x55) (1) 0x0f 0 0 8 7 6 5 4 3 2 1
1WIRE BUS RESET OK
<<<also { command 1WIRE WRITE ROM COMMAND: MATCH (0x55) *follow with 64bit address
1WIRE ADDRESS MACRO 1: 0x2D 0x54 0xD2 0xEF 0x00 0x00 0x00 0x2B '
WRITE: 0x0F
<<<DS2431 write scratch pad command WRITE: 0x00
<<<DS2431 write address byte 1 WRITE: 0x00
<<<DS2431 write address byte 2WRITE: 0x08
<<<start 8 data values to write WRITE: 0x07
WRITE: 0x06
WRITE: 0x05
WRITE: 0x04
WRITE: 0x03
WRITE: 0x02
WRITE: 0x01
1-WIRE>
Next we'll write 8 bytes to a temporary location in the DS2431 called the scratch pad.
Start the transaction with a 1-Wire bus reset and MATCH command (0x55). Both are available as macro '(0x55)'. This can also be done without a macro by typing '{ 0x55', { sends the 1-Wire reset, 0x55 is the 1-Wire MATCH command.
After the MATCH command, send the 8 byte ID of the device to address. We used the macro (1) which was populated with the DS2431 ID in step 1. You could also enter the 8 byte ID manually. At this point the DS2431 should have received it's address and be ready for commands.
0x0f is the write scratch pad command, it tells the DS2431 to expect data. The next two bytes tell it where to put the data, we'll save it at the beginning (0 0). Finally, we send 8 bytes of values to store, the numbers 8 to 1.
You must write a full 8 bytes to the DS2431. Additionally, the write address must be on an 8 byte boundary. See the datasheet for a complete overview of the write limitations.
Step 3, verify the scratch pad and get the authorization code 1-WIRE>(0x55)(1) 0xaa r:3 r:8 r:2 r:2
1WIRE BUS RESET OK
<<<address the device1WIRE WRITE ROM COMMAND: MATCH (0x55) *follow with 64bit address
1WIRE ADDRESS MACRO 1: 0x2D 0x54 0xD2 0xEF 0x00 0x00 0x00 0x2B
WRITE: 0xAA
<<<read scratch pad commandBULK READ 0x03 BYTES:
<<<authorization code0x00 0x00 0x07
BULK READ 0x08 BYTES:
<<<the data we sent0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01
BULK READ 0x02 BYTES:
<<<CRC for the data0xC8 0x86
BULK READ 0x02 BYTES:
<<<all 1s after CRC0xFF 0xFF
1-WIRE>
Verify that the data was received correctly, and get a write authorization code.
Begin again with a 1-Wire reset and MATCH command macro (0x55), and the device address macro (1). This time send the DS2431 read scratch pad command (0xAA), and then read a total of 15 bytes.
The first 3 bytes read (r:3) are the write authorization code, we'll need it in the next step to copy the scratch pad to the EEPROM. The next 8 bytes (r:8) should match the data we sent in step 2. The final 2 bytes (r:2) are a CRC16 for the data. Reads after the CRC return all 1s.
Step 4, write the scratch pad to the EEPROM 1-WIRE>(0x55)(1) 0x55 0x00 0x00 0x07
1WIRE BUS RESET OK
<<<address the device1WIRE WRITE ROM COMMAND: MATCH (0x55) *follow with 64bit address
1WIRE ADDRESS MACRO 1: 0x2D 0x54 0xD2 0xEF 0x00 0x00 0x00 0x2B
WRITE: 0x55
<<<copy scratch pad commandWRITE: 0x00
<<<3 byte authorization code from step 3WRITE: 0x00
WRITE: 0x07
1-WIRE>
We have everything we need to store the scratch pad data permanently in the EEPROM.
Address the device, then send the DS2431 copy scratch pad command (0x55) followed by the three byte authorization code we retrieved in step 3 (0x00 0x00 0x07). If the authorization code is correct, the data is moved to the EEPROM.
Step 5, verify the scratch pad write 1-WIRE>(0x55)(1) 0xaa r:3
1WIRE BUS RESET OK
<<<address the device1WIRE WRITE ROM COMMAND: MATCH (0x55) *follow with 64bit address
1WIRE ADDRESS MACRO 1: 0x2D 0x54 0xD2 0xEF 0x00 0x00 0x00 0x2B
WRITE: 0xAA
<<<read scratch pad commandBULK READ 0x03 BYTES:
0x00 0x00 0x87
<<<updated authorization code1-WIRE>
The DS2431 sets the upper most bit of the write authorization code after a successful copy scratch pad command. Send another read scratch pad command (0xAA) to get the updated authorization code, but just read the first three bytes (r:3). The previous value 0x07 has changed to 0x87, the copy command was received successfully.
Step 6, read back the values 1-WIRE>(0x55)(1) 0xf0 0x00 0x00 r:8 r:8
1WIRE BUS RESET OK
<<<address the device1WIRE WRITE ROM COMMAND: MATCH (0x55) *follow with 64bit address
1WIRE ADDRESS MACRO 1: 0x2D 0x54 0xD2 0xEF 0x00 0x00 0x00 0x2B
WRITE: 0xF0
<<<DS2431 read commandWRITE: 0x00
<<<2 byte read addressWRITE: 0x00
BULK READ 0x08 BYTES:
<<<read the 8 bytes we wrote0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01
BULK READ 0x08 BYTES:
<<<read more values0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
1-WIRE>
Verify the write worked properly by retrieving the values. Address the DS2431, then send the read command (0xf0) and the address to read from(0x00 0x00).
It's possible to read the entire memory range with a single command. We read the eight bytes we wrote earlier (r:8), which returned the expected values. The eight bytes beyond these values haven't been written and return 0.