hallo All! can someone help me! i wrote 04h to my scratchpad memory of DS1994 device but when reading the memory position for the data,i get FF in return!!!!!!!!!!!!! what could be the problem?
thanks
hallo All! can someone help me! i wrote 04h to my scratchpad memory of DS1994 device but when reading the memory position for the data,i get FF in return!!!!!!!!!!!!! what could be the problem?
thanks
.................................................. .................................................. .............hallo ,see code below! Im working with Beck SC12 µC and using beck I2C API to transfer data to DS1994(EEPROM) through DS2482(1-wire-I2C interface device!
void WMatchEEPROM() //matchrom and write to eeprom page
{
uchar bufs0[2];
uchar bufs1[2];
uchar bufs2[2];
uchar bufs3[2];
uchar bufs4[2];
uchar bufs5[2];
uchar bufs6[2];
uchar bufs7[2];
uchar bufs8[2];
uchar bufs9[2];
uchar bufs10[2];
uchar bufs11[2];
uchar bufs12[2];
uchar bufs13[2];
onewreset1(); // 1 wire reset and reading the status register
bufs0[0]=0xA5; // 1 wire write byte
bufs0[1]=0x55; //match rom command
I2C_transmit_block(0x30,bufs0,2);
//I2C_release();
bufs1[0]=0xA5;
bufs1[1]=0x93; //MSB for eeprom address(start)7
I2C_transmit_block(0x30,bufs1,2);
//I2C_release();
bufs2[0]=0xA5;
bufs2[1]=0x00;// 6
I2C_transmit_block(0x30,bufs2,2);
//I2C_release();
bufs3[0]=0xA5;
bufs3[1]=0x00;// 5
I2C_transmit_block(0x30,bufs3,2);
//I2C_release();
bufs4[0]=0xA5;
bufs4[1]=0x00;// 4
I2C_transmit_block(0x30,bufs4,2);
//I2C_release();
bufs5[0]=0xA5;
bufs5[1]=0x14;// 3
I2C_transmit_block(0x30,bufs5,2);
//I2C_release();
bufs6[0]=0xA5;
bufs6[1]=0xA5;// 2
I2C_transmit_block(0x30,bufs6,2);
//I2C_release();
bufs7[0]=0xA5;
bufs7[1]=0x15;// 1
I2C_transmit_block(0x30,bufs7,2);
//I2C_release();
bufs8[0]=0xA5;
bufs8[1]=0x04;//0 LSB, adress end
I2C_transmit_block(0x30,bufs8,2);
I2C_release();
bufs9[0]=0xA5;
bufs9[1]=0x0F;//write scratchpad
I2C_transmit_block(0x30,bufs9,2);
//I2C_release();
bufs10[0]=0xA5;
bufs10[1]=0x00;//Msb of page1 address
I2C_transmit_block(0x30,bufs10,2);
//I2C_release();
bufs11[0]=0xA5;
bufs11[1]=0x26;//Lsb of page 1 address
I2C_transmit_block(0x30,bufs11,2);
//I2C_release();
bufs12[0]=0xA5;
bufs12[1]=0x11;// data to page 1 address
I2C_transmit_block(0x30,bufs12,2);
bufs13[0]=0xA5;
bufs13[1]=0x22;// data to page 1 address
I2C_transmit_block(0x30,bufs13,2);
ReadStatusReg(); //status reg infomation
I2C_release();
}
uchar RMatchEEPROM() //read eeprom page data
{
uchar bufs0[2];
uchar bufs1[2];
uchar bufs2[2];
uchar bufs3[2];
uchar bufs4[2];
uchar bufs5[2];
uchar bufs6[2];
uchar bufs7[2];
uchar bufs8[2];
uchar bufs9[2];
uchar bufx[2];
uchar y,*ptry;
uchar bufs[2];
int i;
onewreset1(); // 1 wire reset and reading the status register
bufs0[0]=0xA5; // 1 wire write byte
bufs0[1]=0x55; //match rom command
I2C_transmit_block(0x30,bufs0,2);
//I2C_release();
bufs1[0]=0xA5;
bufs1[1]=0x93; //MSB for eeprom address(start)7
I2C_transmit_block(0x30,bufs1,2);
//I2C_release();
bufs2[0]=0xA5;
bufs2[1]=0x00;// 6
I2C_transmit_block(0x30,bufs2,2);
//I2C_release();
bufs3[0]=0xA5;
bufs3[1]=0x00;// 5
I2C_transmit_block(0x30,bufs3,2);
//I2C_release();
bufs4[0]=0xA5;
bufs4[1]=0x00;// 4
I2C_transmit_block(0x30,bufs4,2);
//I2C_release();
bufs5[0]=0xA5;
bufs5[1]=0x14;// 3
I2C_transmit_block(0x30,bufs5,2);
//I2C_release();
bufs6[0]=0xA5;
bufs6[1]=0xA5;// 2
I2C_transmit_block(0x30,bufs6,2);
//I2C_release();
bufs7[0]=0xA5;
bufs7[1]=0x15;// 1
I2C_transmit_block(0x30,bufs7,2);
//I2C_release();
bufs8[0]=0xA5;
bufs8[1]=0x04;//0 LSB, adress end
I2C_transmit_block(0x30,bufs8,2);
//I2C_release();
bufs9[0]=0xA5;// 1 wire byte
bufs9[1]=0xAA;//read scratchpad
I2C_transmit_block(0x30,bufs9,2);
for(i=0;i<32;i++)
{
I2C_transmit_char(0x30,0x96); //1 wire readbyte
I2C_release();
//I2C_release();
//bufs[0]=0x96;
//bufs[1]=0x00;//Msb of page2
//I2C_transmit_block(0x30,bufs,2);
//I2C_release();
// bufs[0]=0x96;
// bufs[1]=0x00;//Lsb of page 2
//I2C_transmit_block(0x30,bufs,2);
ReadStatusReg(); //status reg infomation
//I2C_release();
bufx[0]=0xE1;//set readpointer
bufx[1]=0xE1;//to data register
I2C_transmit_block(0x30,bufx,2);
I2C_receive_block(0x30,&y,1);
printf("\n show reg data here!%02x\n",y);
I2C_release();
}
return y;
}
Hallo All,im working with BeckSC12 µC to communicate with DS1994(EEPROM) through DS2484(1 wire -I2C interface device).im also using beck I2C API!
i wrote 00 11 to the EEPROM scratchpad but when reading back,i get aa and a seiries of FF!!!!!!!!!!!!!!what could be the problem!
thanks.
SEE CODE BELOW!!!!!!!!!!!!!!
void WMatchEEPROM() //matchrom and write to eeprom page
{
uchar bufs0[2];
uchar bufs1[2];
uchar bufs2[2];
uchar bufs3[2];
uchar bufs4[2];
uchar bufs5[2];
uchar bufs6[2];
uchar bufs7[2];
uchar bufs8[2];
uchar bufs9[2];
uchar bufs10[2];
uchar bufs11[2];
uchar bufs12[2];
uchar bufs13[2];
onewreset1(); // 1 wire reset and reading the status register
bufs0[0]=0xA5; // 1 wire write byte
bufs0[1]=0x55; //match rom command
I2C_transmit_block(0x30,bufs0,2);
//I2C_release();
bufs1[0]=0xA5;
bufs1[1]=0x93; //MSB for eeprom address(start)7
I2C_transmit_block(0x30,bufs1,2);
//I2C_release();
bufs2[0]=0xA5;
bufs2[1]=0x00;// 6
I2C_transmit_block(0x30,bufs2,2);
//I2C_release();
bufs3[0]=0xA5;
bufs3[1]=0x00;// 5
I2C_transmit_block(0x30,bufs3,2);
//I2C_release();
bufs4[0]=0xA5;
bufs4[1]=0x00;// 4
I2C_transmit_block(0x30,bufs4,2);
//I2C_release();
bufs5[0]=0xA5;
bufs5[1]=0x14;// 3
I2C_transmit_block(0x30,bufs5,2);
//I2C_release();
bufs6[0]=0xA5;
bufs6[1]=0xA5;// 2
I2C_transmit_block(0x30,bufs6,2);
//I2C_release();
bufs7[0]=0xA5;
bufs7[1]=0x15;// 1
I2C_transmit_block(0x30,bufs7,2);
//I2C_release();
bufs8[0]=0xA5;
bufs8[1]=0x04;//0 LSB, adress end
I2C_transmit_block(0x30,bufs8,2);
I2C_release();
bufs9[0]=0xA5;
bufs9[1]=0x0F;//write scratchpad
I2C_transmit_block(0x30,bufs9,2);
//I2C_release();
bufs10[0]=0xA5;
bufs10[1]=0x00;//Msb of page1 address
I2C_transmit_block(0x30,bufs10,2);
//I2C_release();
bufs11[0]=0xA5;
bufs11[1]=0x26;//Lsb of page 1 address
I2C_transmit_block(0x30,bufs11,2);
//I2C_release();
bufs12[0]=0xA5;
bufs12[1]=0x11;// data to page 1 address
I2C_transmit_block(0x30,bufs12,2);
bufs13[0]=0xA5;
bufs13[1]=0x22;// data to page 1 address
I2C_transmit_block(0x30,bufs13,2);
ReadStatusReg(); //status reg infomation
I2C_release();
}
uchar RMatchEEPROM() //read eeprom page data
{
uchar bufs0[2];
uchar bufs1[2];
uchar bufs2[2];
uchar bufs3[2];
uchar bufs4[2];
uchar bufs5[2];
uchar bufs6[2];
uchar bufs7[2];
uchar bufs8[2];
uchar bufs9[2];
uchar bufx[2];
uchar y,*ptry;
uchar bufs[2];
int i;
onewreset1(); // 1 wire reset and reading the status register
bufs0[0]=0xA5; // 1 wire write byte
bufs0[1]=0x55; //match rom command
I2C_transmit_block(0x30,bufs0,2);
//I2C_release();
bufs1[0]=0xA5;
bufs1[1]=0x93; //MSB for eeprom address(start)7
I2C_transmit_block(0x30,bufs1,2);
//I2C_release();
bufs2[0]=0xA5;
bufs2[1]=0x00;// 6
I2C_transmit_block(0x30,bufs2,2);
//I2C_release();
bufs3[0]=0xA5;
bufs3[1]=0x00;// 5
I2C_transmit_block(0x30,bufs3,2);
//I2C_release();
bufs4[0]=0xA5;
bufs4[1]=0x00;// 4
I2C_transmit_block(0x30,bufs4,2);
//I2C_release();
bufs5[0]=0xA5;
bufs5[1]=0x14;// 3
I2C_transmit_block(0x30,bufs5,2);
//I2C_release();
bufs6[0]=0xA5;
bufs6[1]=0xA5;// 2
I2C_transmit_block(0x30,bufs6,2);
//I2C_release();
bufs7[0]=0xA5;
bufs7[1]=0x15;// 1
I2C_transmit_block(0x30,bufs7,2);
//I2C_release();
bufs8[0]=0xA5;
bufs8[1]=0x04;//0 LSB, adress end
I2C_transmit_block(0x30,bufs8,2);
//I2C_release();
bufs9[0]=0xA5;// 1 wire byte
bufs9[1]=0xAA;//read scratchpad
I2C_transmit_block(0x30,bufs9,2);
for(i=0;i<32;i++)
{
I2C_transmit_char(0x30,0x96); //1 wire readbyte
I2C_release();
//I2C_release();
//bufs[0]=0x96;
//bufs[1]=0x00;//Msb of page2
//I2C_transmit_block(0x30,bufs,2);
//I2C_release();
// bufs[0]=0x96;
// bufs[1]=0x00;//Lsb of page 2
//I2C_transmit_block(0x30,bufs,2);
ReadStatusReg(); //status reg infomation
//I2C_release();
bufx[0]=0xE1;//set readpointer
bufx[1]=0xE1;//to data register
I2C_transmit_block(0x30,bufx,2);
I2C_receive_block(0x30,&y,1);
printf("\n show reg data here!%02x\n",y);
I2C_release();
}
return y;
}
Bookmarks