westaust55
Moderator
Programming EPROM memory in 1-Wire devices eg DS2406
As promised, attached is some PICAXE program code to allow one to read the EPROM and Status memory from a DS2406 chip (Dual PIO plus 128bytes of EPROM).
The program firstly reads the EPROM and STATUS memories and displays the contents in the PE F8 terminal window.
I include a check to see if the EPROM memory is totally clear but many may want to delete that.
Next the program writes each byte of data from the PICAXE program1 byte at a time to the DS2406 1-byte scratchpad, checks the 16-bit CRC returns is correct and if so then writes the byte to EPROM memory. If the 16-bit CRC is wrong, the program will try that location one more time before aborting.
The program runs at 8MHz so that PAUSE 1 equates to approx 500microseconds for the typically 480uSec programming pulse.
This is not too crucial but if there is a need to re-write a location (can only make more bits from 1 to 0) the datasheet states that the max cumulative program pulse duration to each EPROM location is 5 milliseconds.
My program as posted only writes data to the first page (32 bytes) of EPROM but is easily modified to write to any location/part of the EPROM.
Also I do not immediately read back the data to check if it is correct. That can be added and another attemp made to write the byte if there are bits = 1 that should be =0 (remember using EPROM you CANNOT change a 0 back to a 1 as with EEPROM).
Once the desired EPROM locations are all written to, the program then displays the new contents of the EPROM memory.
Attached also is a program output as seen on the PE (F8) terminal window.
I built up the small circuit for the 12V programming interface from the Maxim datasheets on a piece of protoboard about 30mm x 30mm. The separate 3V to 12V converter is on a separate board about 30mm x 60mm in dimensions.
As built, the PICAXE pin for the programming signal MUST be made high before the 12V supply is connected. This is because PICAXE outputs are low by default which for the circuit puts the 12V supply onto the 1-Wire line to the non-Master device(s)
The programming interface circuit could be left permanently in the 1-Wire network with the 12V supply disconnected but that does introduce a small voltdrop across the FET transistor, which may influence longer 1-Wire networks, so I would suggest removing entirely from the circuit (DPDT toggle switch would do) unless programming a device with EPROM.
Have fun in a PICAXE world
As promised, attached is some PICAXE program code to allow one to read the EPROM and Status memory from a DS2406 chip (Dual PIO plus 128bytes of EPROM).
The program firstly reads the EPROM and STATUS memories and displays the contents in the PE F8 terminal window.
I include a check to see if the EPROM memory is totally clear but many may want to delete that.
Next the program writes each byte of data from the PICAXE program1 byte at a time to the DS2406 1-byte scratchpad, checks the 16-bit CRC returns is correct and if so then writes the byte to EPROM memory. If the 16-bit CRC is wrong, the program will try that location one more time before aborting.
The program runs at 8MHz so that PAUSE 1 equates to approx 500microseconds for the typically 480uSec programming pulse.
This is not too crucial but if there is a need to re-write a location (can only make more bits from 1 to 0) the datasheet states that the max cumulative program pulse duration to each EPROM location is 5 milliseconds.
My program as posted only writes data to the first page (32 bytes) of EPROM but is easily modified to write to any location/part of the EPROM.
Also I do not immediately read back the data to check if it is correct. That can be added and another attemp made to write the byte if there are bits = 1 that should be =0 (remember using EPROM you CANNOT change a 0 back to a 1 as with EEPROM).
Once the desired EPROM locations are all written to, the program then displays the new contents of the EPROM memory.
Attached also is a program output as seen on the PE (F8) terminal window.
I built up the small circuit for the 12V programming interface from the Maxim datasheets on a piece of protoboard about 30mm x 30mm. The separate 3V to 12V converter is on a separate board about 30mm x 60mm in dimensions.
As built, the PICAXE pin for the programming signal MUST be made high before the 12V supply is connected. This is because PICAXE outputs are low by default which for the circuit puts the 12V supply onto the 1-Wire line to the non-Master device(s)
The programming interface circuit could be left permanently in the 1-Wire network with the 12V supply disconnected but that does introduce a small voltdrop across the FET transistor, which may influence longer 1-Wire networks, so I would suggest removing entirely from the circuit (DPDT toggle switch would do) unless programming a device with EPROM.
Have fun in a PICAXE world
Attachments
-
14.4 KB Views: 82
-
5.1 KB Views: 64