DS2431 Read/Write Register

Interesting examples and tutorials about REVELPROG-IS features and device programming
farid_aal
Posts: 1
Joined: Wed Sep 02, 2020 8:00 pm
Has thanked: 1 time

DS2431 Read/Write Register

Postby farid_aal » Wed Sep 02, 2020 8:23 pm

Hi,

How to read/write the memory register of the DS2431 at address 080h-08Fh?
Maybe you can help me to create the script.
https://datasheets.maximintegrated.com/en/ds/DS2431.pdf
See page 7 for memory mapping
Attachments
DS2431.JPG
DS2431.JPG (89.82 KiB) Viewed 6486 times

ArT
Posts: 1497
Joined: Wed Mar 25, 2015 8:54 am
Location: Warsaw, Poland
Has thanked: 51 times
Been thanked: 160 times

Re: DS2431 Read/Write Register

Postby ArT » Thu Sep 03, 2020 11:28 am

Here you have example script for DS2436 chip:
viewtopic.php?f=32&t=436
it have few things common, but there are also differences, so I prepared you read/write script for DS2431 below.

Here is described script tool:
viewtopic.php?f=32&t=280

DS2431 read / write register scripts:
READ - it reads 4 protection control bytes + 1 copy protection byte + 1 factory byte + 2 user bytes = 8 bytes in total

Code: Select all

// DS2431
// Read registers from address 80h-87h

#SCRIPT HEADER;
SCRIPT:v1.8.2;

#HARDWARE SETTINGS;
HW:1-WIRE,4.5V,SLOW;

// Protection Control Byte 0-3
#OPERATION;
SW:0,0,1,3,0,0,0,0,0,500;
INSTR:CC, F0, 80, 00; // SKIP ROM + READ MEMORY (4 bytes) + START ADDR

// Copy Protection Byte
#OPERATION;
SW:0,0,1,0,0,0,0,0,0,500;
INSTR:CC, F0, 84, 00; // SKIP ROM + READ MEMORY (4 bytes) + START ADDR

// Factory Byte. Set at Factory
#OPERATION;
SW:0,0,1,0,0,0,0,0,0,500;
INSTR:CC, F0, 85, 00; // SKIP ROM + READ MEMORY (1 byte) + START ADDR

// User byte/Manufacturer ID (2 bytes)
#OPERATION;
SW:0,0,1,1,0,0,0,0,0,500;
INSTR:CC, F0, 86, 00; // SKIP ROM + READ MEMORY (2 bytes) + START ADDR


WRITE - please note that chip should have registers in factory reset state. Datasheet says "Once programmed to AAh or 55h this address becomes read only. All other codes can be stored, but neither write protect the address nor activate any function" so be careful. Writing procedure is described in datasheet page 8 and on page 9 you have flow diagram which I used to prepare you writing scripts below:

Code: Select all

// DS2431
// Write registers at 80h-87h

#SCRIPT HEADER;
SCRIPT:v1.8.2;

#HARDWARE SETTINGS;
HW:1-WIRE,5.0V,SLOW;

// STEP 1 - Write Scratchpad (write 8 data bytes to registers)
#OPERATION;
SW:1,7,0,0,0,0,0,10,0,500;
INSTR: CC, 0F, 80, 00; // SKIP ROM + Write Scratchpad + TA1 [7:0] target address LSB + TA2 [15:8] target address MSB
DATA: 00,00,00,00,00,55,12,34; // Write 8 byte register (Protection Control Byte 0,1,2,3 + copy protection byte + dummy byte + user ID1 + user ID2)

// STEP 2 - Read Scratchpad (TA1 + TA2 + ES + 8 DATA BYTE = 11 bytes total)
// 1st byte should be equal to TA1 from Step 1
// 2nd byte should be equal to TA2 from Step 1
// 3rd byte is AUTHORIZATION CODE which should be used in next step
// 4rd byte should be equal to data byte from Step 1
#OPERATION;
SW:0,0,1,10,0,0,0,0,0,500;
INSTR:CC, AA; // SKIP ROM + READ Scratchpad

// STEP3 - Copy Scratchpad
// Please note - you need to first execute STEP1 and STEP2 to read autorhization code (3rd byte in step2) and use this autorization code last byte in below instruction
#OPERATION;
SW:0,0,0,0,0,0,10,0,0,500;
INSTR:CC, 55, 80, 00, 07; // SKIP ROM + COPY Scratchpad + TA1 (from step1) + TA2 (from step1) + AUTHORIZATION CODE (3rd byte read in STEP 2)


Please note:
- you can set 8 registers bytes in STEP 1 in DATA field (6rd byte is read only byte that's why it's dummy 55h here) - in above example I'm writing zeros to protection registers and 0x12 and 0x34 in user bytes
- please note that if you set 55h or 11h in first 5 bytes (address 80h 81h 82h 83h 84h) then this address becomes read only - you will lost possibility to change it later
- step 2 will read you 11 bytes in total - 3rd byte is authorization code which should be used in step 3 (without valid authorization code write will fail) - in my example it reads: 80 00 07 00 00 00 00 00 55 12 34 where 3rd byte (07) is authorization code which should be used in step 3 (INSTR:CC, 55, 80, 00, 07;)

I tested it with DS2431 in TO92 package and everything works.
Please let me know about results, hope it helps!
Attachments
RPscript_1wire_DS2431_ReadRegisters.txt
(714 Bytes) Downloaded 374 times
RPscript_1wire_DS2431_WriteRegisters.txt
(1.23 KiB) Downloaded 345 times


Return to “Tutorials and Examples”

Who is online

Users browsing this forum: No registered users and 3 guests