- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can i using EZUSB_WriteI2C() and EZUSB_ReadI2C() functions to read/write Data from Si570 - 570FAB000433DG such as image?
I am using Keil C and modify firmware of Cypress. Could you please tell me detail how to read/write data with I2C?
Thank you very much and sorry about my english
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please use the following cases when FX2LP is set as I2C master-
Please set I2C_Addr as your Si570 slave address and DB_Addr as 0x00. Please set the LSB in addr to your internal register address. The length should be the size of the data so in this case 0x06.
EEPROMWrite(addr, length, test_array);
This will ensure that the first parameter passed to the function is the internal register address (one byte), second parameter is the length of the actual bytes to be written and the third parameter is the buffer storing the data to be written.
EEPROMRead(addr, length ,(WORD)EP0BUF);
This will ensure that the first parameter passed to the function is the internal register address (one byte), second parameter is the length of the bytes to be read and the third parameter is the buffer storing the read data. Please arm EP0BCL with the length passed on the read function if you would like to read the data on EP0.
Please probe the I2C lines and let us know what is seen if this doesnt work.
Best Regards,
Sananya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please refer to the KBA for reference on using the EZUSB I2C Read/Write functions. For the Si570, please ensure that the first data byte sent in the function is a byte address as shown in the example commands.
You could also refer to the Vendax firmware in the App Note which performs I2C Read and Write operations to an EEPROM.
Best Regards,
Sananya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your response. I will try it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I found a function regarding Si570 I2C.
****************************************************************************************
* Function: Si570_ReadRegs(void) *
* *
* Input: None *
* *
* Output: tempBuf *
* *
* Overview: Read the Si570 registers *
* *
* *
***************************************************************************************/
void Si570_ReadRegs(void)
{
uint8 i;
for (i=0; i<6; i++) // Data to Si570
{
Si570_MasterSendStart(Si570_address, 0u); // Write
Si570_MasterWriteByte(i+7); // specify register, start with R7
Si570_MasterSendRestart(Si570_address, 1u); // Read
Si570_tempBuf = Si570_MasterReadByte(1u); // Read data from R
Si570_MasterSendStop(); // Send Stop
}
}
And this is my code in Cypress FX2LP
DB_Addr = 0x00;
I2C_Addr = 0x00;
test_array[0] = 0x07;
test_array[1] = 0x08;
test_array[2] = 0x09;
test_array[3] = 0x0A;
test_array[4] = 0x0B;
test_array[5] = 0x0C;
for(j =0; j< 6; j ++){
i2cWriteBuf[0] = 0x00; //For Write
i2cWriteBuf[1]= test_array
i2cWriteBuf[2] = 0x00; //Slave address
i2cWriteBuf[3] = 0x01; // For Read
EEPROMWrite(DB_Addr,(WORD)4,(WORD)i2cWriteBuf);
EEPROMRead(DB_Addr,(WORD)1,(WORD)i2cReadBuf);
*(EP0BUF+j) = i2cReadBuf;
}
But it not work.
This is datasheet
https://www.mouser.vn/datasheet/2/368/Si570-1111020.pdf
Please help me to correct. Thanks so much!
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please use the following cases when FX2LP is set as I2C master-
Please set I2C_Addr as your Si570 slave address and DB_Addr as 0x00. Please set the LSB in addr to your internal register address. The length should be the size of the data so in this case 0x06.
EEPROMWrite(addr, length, test_array);
This will ensure that the first parameter passed to the function is the internal register address (one byte), second parameter is the length of the actual bytes to be written and the third parameter is the buffer storing the data to be written.
EEPROMRead(addr, length ,(WORD)EP0BUF);
This will ensure that the first parameter passed to the function is the internal register address (one byte), second parameter is the length of the bytes to be read and the third parameter is the buffer storing the read data. Please arm EP0BCL with the length passed on the read function if you would like to read the data on EP0.
Please probe the I2C lines and let us know what is seen if this doesnt work.
Best Regards,
Sananya