- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is datasheet of Si570:
https://www.silabs.com/documents/public/data-sheets/si570.pdf
I want to read start-up frequency configuration (RFREQ, HS_DIV, and N1) from the device after power-up or register reset (page 18).
The control interface to the Si570 is an I2C-compatible 2-wire bus for bidirectional communication.
How to I read/write start-up frequency by i2c of Cypress USB framework.
I using C:\Cypress\USB\CY3684_EZ-USB_FX2LP_DVK\1.1\Firmware\Vend_ax
This is my code:
DB_Addr = 0x00;
I2C_Addr = 0x00;
byte_array[0] = 0x07;
byte_array[1] = 0x08;
byte_array[2] = 0x09;
byte_array[3] = 0x0A;
byte_array[4] = 0x0B;
byte_array[5] = 0x0C;
for(j =0; j< 6; j ++){
EP0BCH = 0;
EP0BCL = 0; // Clear bytecount to allow new data in; also stops NAKing
iicWriteBuf[0] = 0x00;
iicWriteBuf[1]= byte_array
iicWriteBuf[2] = 0x00;
iicWriteBuf[3] = 0x01;
EEPROMWrite(DB_Addr,(WORD)4,(WORD)iicWriteBuf);
EEPROMRead(DB_Addr,(WORD)1,(WORD)iicReadBuf);
*(EP0BUF+j) = iicReadBuf;
}
EP0BCH = 0;
EP0BCL = 6;
EP0CS|= bmHSNAK;
But it not work, please help me to correct.
Thank you!
Best Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
For reading n bytes of data from a device with slave address and from register address you will need to write the slave register address first and then perform a read operation.
If you are using the vendax firmware as an example, you can just use the EEPROMRead() function for reading the required data from the slave device, as the write part is also handled in the function.
Since your slave has single byte register address.
Please replace the existing EEPROMRead function in the firmware with the below function:
void EEPROMRead(BYTE addr, BYTE length, BYTE xdata *buf)
{
BYTE i = 1;
I2C_Addr = 0x01; //replace your slave device address here
EZUSB_WriteI2C(I2C_Addr, i, addr);
EZUSB_ReadI2C(I2C_Addr, length, buf);
}
Please change the prototype declaration as well in the start of VEND_AX.C firmware.
void EEPROMRead(BYTE addr, BYTE length, BYTE xdata *buf); //TPM EEPROM Read
In the EEPROMRead() function, I2C_Addr variable should be re-assigned in the start with the proper address of the slave device which you are using.
the first parameter passed to EEPROMRead() should be the register address (in BYTE format) from which you will be reading the frequency values. ()
The second parameter is the number of bytes to be starting from the register address specified.
The third parameter should be a pointer to the buffer where the read data should be stored. You can pass a pointer to the EP0 buffer EP0BUF or any other endpoint buffer which is configured as an IN end point.
Please note that in the control center you will need to do a control IN transfer with req type as vendor , target: device, req code: <your firmware switch case value where you are handling the request> , bytes to be transferred should be set to the number of bytes you are requesting from the FX2LP device.
Please refer to the screenshot below where i have requested for the chip revision.
Thanks,
Yatheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
For reading n bytes of data from a device with slave address and from register address you will need to write the slave register address first and then perform a read operation.
If you are using the vendax firmware as an example, you can just use the EEPROMRead() function for reading the required data from the slave device, as the write part is also handled in the function.
Since your slave has single byte register address.
Please replace the existing EEPROMRead function in the firmware with the below function:
void EEPROMRead(BYTE addr, BYTE length, BYTE xdata *buf)
{
BYTE i = 1;
I2C_Addr = 0x01; //replace your slave device address here
EZUSB_WriteI2C(I2C_Addr, i, addr);
EZUSB_ReadI2C(I2C_Addr, length, buf);
}
Please change the prototype declaration as well in the start of VEND_AX.C firmware.
void EEPROMRead(BYTE addr, BYTE length, BYTE xdata *buf); //TPM EEPROM Read
In the EEPROMRead() function, I2C_Addr variable should be re-assigned in the start with the proper address of the slave device which you are using.
the first parameter passed to EEPROMRead() should be the register address (in BYTE format) from which you will be reading the frequency values. ()
The second parameter is the number of bytes to be starting from the register address specified.
The third parameter should be a pointer to the buffer where the read data should be stored. You can pass a pointer to the EP0 buffer EP0BUF or any other endpoint buffer which is configured as an IN end point.
Please note that in the control center you will need to do a control IN transfer with req type as vendor , target: device, req code: <your firmware switch case value where you are handling the request> , bytes to be transferred should be set to the number of bytes you are requesting from the FX2LP device.
Please refer to the screenshot below where i have requested for the chip revision.
Thanks,
Yatheesh