how would i use a DS2431 1K EEPROM from maxim with an arduino? i have searched google but havent found anything on using it with an arduino jus a bus pirate . thanx for any help
?
You need to master two areas....
=====
- Talking to 1-Wire devices in general via Arduino. There are two approaches....
a) Talking via a simple ASCII serial protocol to a 1-Wire interface which under this approach is the MicroLan's host.
For this, see...
b) Directly driving a Microlan (one or more 1-Wire chips connected to a master, or host, which in this case would be the Arduino)
For this, see stuff at Arduino site about 1-Wire library
==========
2) Talking to the DS2431 to "do" the things you can do with it.
Once you've mastered the "talking to 1-Wire" stuff, what you need to learn to talk to the DS2431 is independent of the host you are using. Lots of stuff on 1-Wire chips, e.g.
Hi, I've wrote some code to access the ds2431 with the one wire 2 library. Just use it to get quickly started. Hope it helps somebody, tell me if you used it!
There is some utility function, but the 2 most important function are these one:
void WriteRow(byte row, byte* buffer)
in the main memory, there are 16 rows of 8 byte for a total of 1024 bits
so buffer is an array with your 8 bytes of data and you can access row 0 to 15
void ReadAllMem();
it prints the entire content of main memory, replace the printing code with what you want to save the data.
#include <OneWire.h>
OneWire ds(2); // 1-wire on pin 2
byte addr[8]; // Contains the eeprom unique ID
void setup(void)
{
Serial.begin(9600);
}
void loop(void)
{
byte i;
byte dat[13];
SearchAddress(addr);
dat[0] = 0x01;
dat[1] = 0x02;
dat[2] = 0x03;
dat[3] = 0x04;
dat[4] = 0x05;
dat[5] = 0x06;
dat[6] = 0x07;
dat[7] = 0x08;
WriteRow(0,dat);
ReadAllMem(); //print all mem content
while(1);
}
void SearchAddress(byte* address) //Search for address and confirm it
{
int i;
if ( !ds.search(address))
{
Serial.print("No device found.\n");
ds.reset_search();
delay(250);
return;
}
Serial.print("ADDR= ");
for( i = 0; i < 8; i++)
{
Serial.print(address[i], HEX);
Serial.print(" ");
}
if ( OneWire::crc8( address, 7) != address[7])
{
Serial.print("CRC is not valid, address is corrupted\n");
return;
}
if ( address[0] != 0x2D)
{
Serial.print("Device is not a 1-wire Eeprom.\n");
return;
}
Serial.println();
}
void WriteReadScratchPad(byte TA1, byte TA2, byte* data)
{
int i;
ds.reset();
ds.select(addr);
ds.write(0x0F,1); // Write ScratchPad
ds.write(TA1,1);
ds.write(TA2,1);
for ( i = 0; i < 8; i++)
ds.write(data[i],1);
ds.reset();
ds.select(addr);
ds.write(0xAA); // Read Scratchpad
for ( i = 0; i < 13; i++)
data[i] = ds.read();
}
void CopyScratchPad(byte* data)
{
ds.reset();
ds.select(addr);
ds.write(0x55,1); // Copy ScratchPad
ds.write(data[0],1);
ds.write(data[1],1); // Send TA1 TA2 and ES for copy authorization
ds.write(data[2],1);
delay(25); // Waiting for copy completion
//Serial.print("Copy done!\n");
}
void ReadAllMem()
{
int i;
ds.reset();
ds.select(addr);
ds.write(0xF0,1); // Read Memory
ds.write(0x00,1); //Read Offset 0000h
ds.write(0x00,1);
for ( i = 0; i < 128; i++) //whole mem is 144
{
Serial.print(ds.read(), HEX);
//Serial.print(" ");
}
Serial.println();
}
void WriteRow(byte row, byte* buffer)
{
int i;
if (row < 0 || row > 15) //There are 16 row of 8 bytes in the main memory
return; //The remaining are for the 64 bits register page
WriteReadScratchPad(row*8, 0x00, buffer);
/* Print result of the ReadScratchPad
for ( i = 0; i < 13; i++)
{
Serial.print(buffer[i], HEX);
Serial.print(" ");
}
*/
CopyScratchPad(buffer);
}